不知道叫什么の做题记录
1.P10730 [NOISG 2023 Qualification] Burgers
考虑对答案进行二分,之前比赛见到过一题类似的。
然后就是对于答案的 check。乱设乱搞分类讨论就好了。忘了就去看题解区。
::::success[Code]
/*
It's been a long day.
Without my friend.
And I'll tell you all about it when I see you again.
We've come a long way,
From where we began.
Oh I'll tell you all about it when I see you again.
When I see you again.
Oh,who know,all the planes we flew,
good things we had been drew
That something told me right here talking with you.
*/
//#pragma GCC optimize(1)
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define dep(i,x,y) for(int i=x;i>=y;--i)
#define int long long
#define N 100005
#define endl "\n"
#define MAX 1145141919810
using namespace std;
inline int read(){
int ret=0,sgn=0,ch=getchar();
while(!isdigit(ch))sgn|=ch=='-',ch=getchar();
while(isdigit(ch))ret=ret*10+ch-'0',ch=getchar();
return sgn?-ret:ret;
}
int x[N],a[N],b[N],n;
inline bool check(int y){
int l=0,r=y;
for(int i=1;i<=n&&l<=r;++i){
if(a[i]==b[i]&&x[i]<1ll*y*b[i])return false;
if(a[i]>b[i])r=min(1ll*r,(x[i]-1ll*y*b[i])/(a[i]-b[i]));
if(a[i]<b[i])l=max(1ll*l,(x[i]-1ll*y*b[i]+a[i]-b[i]+1)/(a[i]-b[i]));
}
if(l>r)return false;
return true;
}
inline void Feather(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
mt19937 Rand(time(0));
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
rep(i,1,n)cin>>x[i];
rep(i,1,n)cin>>a[i];
rep(i,1,n)cin>>b[i];
int l=0,r=1e9;
while(l<r){
int mid=(l+r+1)/2;
if(check(mid))l=mid;
else r=mid-1;
}
cout<<l;
}
signed main(){Feather();return 0;}
::::
2.P13541 [OOI 2022] Good arrays
戳这里,看看自己的题解。
3.CF2178D Xmas or Hysteria
首先
然后考虑
如果
::::success[Code]
/*
It's been a long day.
Without my friend.
And I'll tell you all about it when I see you again.
We've come a long way,
From where we began.
Oh I'll tell you all about it when I see you again.
When I see you again.
Oh,who know,all the planes we flew,
good things we had been drew
That something told me right here talking with you.
*/
//#pragma GCC optimize(1)
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define dep(i,x,y) for(int i=x;i>=y;--i)
#define int long long
#define N 200005
#define endl "\n"
#define MAX 1145141919810
using namespace std;
inline int read(){
int ret=0,sgn=0,ch=getchar();
while(!isdigit(ch))sgn|=ch=='-',ch=getchar();
while(isdigit(ch))ret=ret*10+ch-'0',ch=getchar();
return sgn?-ret:ret;
}
struct node{
int a,h,id;
}a[N];
int T,m,n,total,ing[N];
inline bool cmp(node x,node y){
return x.a<y.a;
}
inline void Feather(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
mt19937 Rand(time(0));
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>T;
while(T--){
total=0;
cin>>n>>m;
rep(i,1,n){
total+=a[i].a;
cin>>a[i].a;
a[i].h=a[i].a;
a[i].id=i;
}
if(m>n/2){cout<<-1<<endl;continue;}
sort(a+1,a+n+1,cmp);
if(m==n/2){
cout<<n/2<<endl;
int l=1,r=n;
while(l<=r){
cout<<a[r].id<<' '<<a[l].id<<endl;
++l;--r;
}
}
else if(m==0){
total-=a[n].a;
if(total<a[n].a){cout<<-1;continue;}
cout<<n-1<<endl;
int tmp=0,kk;
dep(i,n-1,1){
tmp+=a[i].a;
if(tmp>=a[n].a){
kk=i;
break;
}
}
rep(i,1,kk-1)cout<<a[i].id<<' '<<a[i+1].id<<endl;
rep(i,kk,n-1)cout<<a[i].id<<' '<<a[n].id<<endl;
}
else{
cout<<n-m*2+m<<endl;
int st=1;
while(m!=(n-st+1)/2){
cout<<a[st].id<<' '<<a[st+1].id<<endl;
++st;
}
int l=st,r=n;
while(l<=r){
cout<<a[r].id<<' '<<a[l].id<<endl;
++l;--r;
}
}
}
}
signed main(){Feather();return 0;}
::::