Submission #1021633

#TimeUsernameProblemLanguageResultExecution timeMemory
1021633vjudge1Archery (IOI09_archery)C++17
0 / 100
232 ms23808 KiB
#include<bits/stdc++.h> #define N 1<<19 #pragma GCC optimize(2) typedef long long ll; #define int ll using namespace std; struct fenwick_tree{ ll T[N]{}; void upd(int x,int p){ while(x<N) T[x]+=p,x+=x&-x; } ll qr(int x){ int ans=0; while(x) ans+=T[x],x-=x&-x; return ans; } } X,cnt; int h,g,p[N],CC,CC2; pair<ll,ll>b; void stuff(ll x,int i,ll A,ll B){ int l=0,r=5e5,res=0; while(l<=r){ int mid=l+r>>1; if(X.qr(mid)<=x) l=mid+1,res=mid; else r=mid-1; } ll K=cnt.qr(res),C=X.qr(res); if(K>h||K==h&&b.first*B>b.second*A*C) h=K,b={A*C,B},g=i; } #undef int signed main(){ cin.tie(0)->sync_with_stdio(0); set<pair<int,int>>st; vector<tuple<int,int,int>>v; int n; ll w; cin>>n>>w; for(int i=1;i<=n;i++){ int q,s; cin>>s>>q; st.insert({q,i}); v.push_back({q,s,i}); } for(auto[q,i]:st) p[i]=++CC; sort(v.begin(),v.end(),[](auto a,auto b){ return get<1>(a)*get<0>(b)<get<0>(a)*get<1>(b); }); for(auto[q,s,i]:v){ X.upd(p[i],q); cnt.upd(p[i],1); stuff(w*q/s,++CC2,s,q); } vector<pair<int,int>>v2; for(int i=0;i<g;i++) v2.push_back({get<0>(v[i]),get<2>(v[i])}); sort(v2.begin(),v2.end()); cout<<h<<'\n'; for(int i=0;i<h;i++) cout<<v2[i].second<<'\n'; }

Compilation message (stderr)

archery.cpp: In function 'void stuff(ll, ll, ll, ll)':
archery.cpp:25:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   25 |         int mid=l+r>>1;
      |                 ~^~
archery.cpp:31:17: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   31 |     if(K>h||K==h&&b.first*B>b.second*A*C)
      |             ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...