Submission #1027632

#TimeUsernameProblemLanguageResultExecution timeMemory
1027632vjudge1Rice Hub (IOI11_ricehub)C++17
0 / 100
38 ms860 KiB
#include <bits/stdc++.h> using namespace std; int besthub(int n, int l, int x[], long long b) { int a[l+1]; memset(a, 0, sizeof(a)); for(int i=0; i<n; i++) a[x[i]]=1; long long max_rez=-1, sol=0; for(int i=1; i<=l; i++) { int bb=b; int rezz=a[i]; for(int j=i-1, k=i+1; j>0 || k<=l; k++, j--) { if(j>0 && a[j]==1 && bb-(i-j)>=0) { bb-=(i-j); rezz++; } else if(j>0 && bb-(i-j)<0) break; if(k<=l && a[k]==1 && bb-(k-i)>=0) { bb-=(k-i); rezz++; } else if(k<=l && bb-(k-i)<0) break; } if(max_rez<rezz) { max_rez=rezz; sol=i; } } return sol; } /*int main() { int r, l; long long b; cin>>r>>l; int x[r]; for(int i=0; i<r; i++) cin>>x[i]; cin>>b; cout<<besthub(r, l, x, b); return 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...