Submission #557177

#TimeUsernameProblemLanguageResultExecution timeMemory
557177n0sk1llRice Hub (IOI11_ricehub)C++14
17 / 100
14 ms1760 KiB
#include "ricehub.h" #include<bits/stdc++.h> using namespace std; long long int typedef li; int besthub(int n, int m, int x[], li b) { int mx=0; li balans=0; int l=0,r=0; for (int i=0;i<n;i++) if (balans+(x[i]-x[0])<=b) balans+=(x[i]-x[0]),r++; //cout<<0<<": "<<"["<<l<<","<<r<<") - "<<balans<<endl; for (int i=1;i<n;i++) { balans+=(li)(i-l)*(x[i]-x[i-1]); balans-=(li)(r-i)*(x[i]-x[i-1]); //cout<<i<<": "<<"["<<l<<","<<r<<") - "<<balans<<endl; while (balans>b) balans-=(x[i]-x[l]),l++; while (r<n && balans+(x[r]-x[i])<=b) balans+=(x[r]-x[i]),r++; mx=max(mx,r-l); //cout<<i<<": "<<"["<<l<<","<<r<<") - "<<balans<<endl; //cout<<endl; } return mx; } /* 5 20 6 1 2 10 12 14 3 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...