Switzerland round P1309
answer
1. This problem can simulate what
2.sort oxygen can live (sort might be a bit slow, you are not meeting T)
Note sort sorting:
return 1 satisfying the condition, does not exchange
return 0 is not satisfied, the exchange
Code (oxygen optimize a bit QWQ)
// luogu-judger-enable-o2 #include<bits/stdc++.h> using namespace std; int n,r,q; struct node { int s,num,w; }peo[200002]; bool cmp(node x,node y) { if(x.s >y.s ) return 1; if(x.s <y.s ) return 0; if(x.s ==y.s ) { if(x.num <y.num ) return 1; else return 0; } } int main() { scanf("%d%d%d",&n,&r,&q); n=2*n; for(int i=1;i<=n;i++) { scanf("%d",&peo[i].s ); peo[i].num =i; } for(int i=1;i<=n;i++) scanf("%d",&peo[i].w ); for(int k=1;k<=r;k++) { sort(peo+1,peo+n+1,cmp); for(int i=1;i<=n;i+=2) { if(peo[i].w <peo[i+1].w ) peo[i+1].s ++; else peo[i].s ++; } } sort(peo+1,peo+n+1,cmp); printf("%d",peo[q].num ); }