Submission #70643

#TimeUsernameProblemLanguageResultExecution timeMemory
70643Sa1378Teams (IOI15_teams)C++17
0 / 100
138 ms36656 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; #define N ((int)501*1000) #define K ((int)22) int n,pos[N]; pair <int,int> a[N]; int seg[K][N]; void build(int xl=0,int xr=n,int h=0) { if(xl==xr-1) { seg[h][xl]=a[xl].second; return ; } int mid=(xl+xr)/2; build(xl,mid,h+1); build(mid,xr,h+1); merge(seg[h+1]+xl,seg[h+1]+mid,seg[h+1]+mid,seg[h+1]+xr,seg[h]+xl); } int query(int q,int val,int xl=0,int xr=n,int h=0) { int res=0; for(int i=0;i<q;i++) if(a[i].second>=val) res++; return res; /* if(xr<=q)return xr-(lower_bound(seg[h]+xl,seg[h]+xr,val)-(seg[h]+xl)); int mid=(xl+xr)/2; int res=query(q,val,xl,mid,h+1); if(mid<q)res+=query(q,val,mid,xr,h+1); return res;*/ } void init(int n2, int A[], int B[]) { n=n2; for(int i=0;i<n;i++)a[i]={A[i],B[i]}; sort(a,a+n); for(int i=1,j=0;i<=n;i++) { while(j<n && a[j].first<=i)j++; pos[i]=j; } // build(); } int can(int m, int k[]) { int minus=0; sort(k,k+m); k[m]=N; for(int i=0;i<m;i++) { int x=query(pos[k[i]],k[i+1]); int y=query(pos[k[i]],k[i])-x; if(y>=minus)y-=minus; else x-=minus-y,y=0; if(x+y<k[i])return 0; minus=max(0,k[i]-y); } return 1; }

Compilation message (stderr)

teams.cpp: In function 'int query(int, int, int, int, int)':
teams.cpp:24:32: warning: unused parameter 'xl' [-Wunused-parameter]
 int query(int q,int val,int xl=0,int xr=n,int h=0)
                                ^
teams.cpp:24:41: warning: unused parameter 'xr' [-Wunused-parameter]
 int query(int q,int val,int xl=0,int xr=n,int h=0)
                                         ^
teams.cpp:24:49: warning: unused parameter 'h' [-Wunused-parameter]
 int query(int q,int val,int xl=0,int xr=n,int h=0)
                                                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...