题目
L1都很简单,今年也没有什么坑点,就是第三题if else有点麻烦。
L1-1
printf
L1-2
输出a/b
L1-3
模拟,比较麻烦,不知道怎么写比较简单.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<complex>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<unordered_map>
#include<list>
#include<set>
#include<queue>
#include<stack>
#define OldTomato ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define fir(i,a,b) for(int i=a;i<=b;++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define p_ priority_queue
// round() 四舍五入 ceil() 向上取整 floor() 向下取整
// lower_bound(a.begin(),a.end(),tmp,greater<ll>()) 第一个小于等于的
// #define int long long //QAQ
using namespace std;
typedef complex<double> CP;
typedef pair<int,int> PII;
typedef long long ll;
// typedef __int128 it;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll inf = 1e18;
const int N = 2e5+10;
const int M = 1e6+10;
const int mod = 1e9+7;
const double eps = 1e-6;
inline int lowbit(int x){ return x&(-x);}
template<typename T>void write(T x)
{
if(x<0)
{
putchar('-');
x=-x;
}
if(x>9)
{
write(x/10);
}
putchar(x%10+'0');
}
template<typename T> void read(T &x)
{
x = 0;char ch = getchar();ll f = 1;
while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
int n,m,k,T;
int a[3];
bool vis[3];
int l,r;
int mx = 0;
void solve()
{
n = 2;
cin>>l>>r>>a[0]>>a[1];
for(int i=0;i<n;++i)
{
mx = max(mx,a[i]);
if(a[i] > l) vis[i] = 1;
else
{
if(a[i^1]>=r) vis[i] = 1;
}
}
printf("%d-",a[0]); if(vis[0]) printf("Y");else printf("N"); printf(" ");
printf("%d-",a[1]); if(vis[1]) printf("Y");else printf("N"); printf("\n");
if(min(a[0],a[1])>=l)
{
cout<<"huan ying ru guan";
}
else if(max(a[0],a[1])<l)
{
cout<<"zhang da zai lai ba";
}
else
{
if(max(a[0],a[1]) >= r)
{
if(a[0] > a[1]) printf("qing 1 zhao gu hao 2");
else printf("qing 2 zhao gu hao 1");
}
else
{
if(a[0] > a[1]) printf("1: huan ying ru guan");
else printf("2: huan ying ru guan");
}
}
}
signed main(void)
{
T = 1;
// OldTomato; cin>>T;
// read(T);
while(T--)
{
solve();
}
return 0;
}
L1-4
printf
L1-5
模拟,拿标记数组标记一下即可。
L1-6
按题意模拟
L1-7
模拟即可.
L1-8
维护值域数组,并且排序。每次从高到低枚举天梯赛分数,先弹出数组开头、再把所有满足PAT分数的数组尾弹出。
代码:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<complex>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<unordered_map>
#include<list>
#include<set>
#include<queue>
#include<stack>
#define OldTomato ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define fir(i,a,b) for(int i=a;i<=b;++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define p_ priority_queue
// round() 四舍五入 ceil() 向上取整 floor() 向下取整
// lower_bound(a.begin(),a.end(),tmp,greater<ll>()) 第一个小于等于的
// #define int long long //QAQ
using namespace std;
typedef complex<double> CP;
typedef pair<int,int> PII;
typedef long long ll;
// typedef __int128 it;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll inf = 1e18;
const int N = 2e5+10;
const int M = 1e6+10;
const int mod = 1e9+7;
const double eps = 1e-6;
inline int lowbit(int x){ return x&(-x);}
template<typename T>void write(T x)
{
if(x<0)
{
putchar('-');
x=-x;
}
if(x>9)
{
write(x/10);
}
putchar(x%10+'0');
}
template<typename T> void read(T &x)
{
x = 0;char ch = getchar();ll f = 1;
while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
int n,m,k,T;
vector<int> va[300];
void solve()
{
cin>>n>>k>>m;
for(int i=0;i<n;++i)
{
int x,y; cin>>x>>y;
if(x>=175) va[x].push_back(y);
}
for(int i=175;i<=290;++i) sort(va[i].begin(),va[i].end());
int ans = 0;
while(k--)
{
for(int i=290;i>=175;--i)
{
if(va[i].size())
{
ans++;
va[i].erase(va[i].begin());
while(va[i].size()&&va[i].back()>=m) ans++,va[i].pop_back();
}
}
}
cout<<ans;
}
signed main(void)
{
T = 1;
// OldTomato; cin>>T;
// read(T);
while(T--)
{
solve();
}
return 0;
}