Submission #895527

#TimeUsernameProblemLanguageResultExecution timeMemory
895527nbphongWatching (JOI13_watching)C++14
0 / 100
1063 ms348 KiB
#define ll long long #define se second #define fi first #define ll long long #define pb push_back #define oo 2005 #define pii pair<int,int> #include <bits/stdc++.h> using namespace std; ll n,nho,lon,a[oo]; void sub1() { int i,j,vtm,vtb,tam; for(ll w=1;w<=1000000000;w++) { ll small=w; ll big=2*w; i=1; j=1; int anhnho=nho; int anhlon=lon; vtm=INT_MIN,vtb=INT_MIN; while(true) { if(j>n) break; if(i==n&&j==n&&(anhnho>0||anhlon>0)) { cout<<w; return; } tam=a[j]-a[i]; if(tam<=small) { vtm=max(vtm,j); } if(tam<=big&&tam>small) { vtb=max(vtb,j); } if(anhlon<0||anhnho<0) break; if(tam>big) { if(anhlon>0&&vtb!=INT_MIN) { i=vtb+1; j=vtb; anhlon--; vtm=INT_MIN,vtb=INT_MIN; } else { if(anhnho>0&&vtm!=INT_MIN) { i=vtm+1; j=vtm; anhnho--; vtm=INT_MIN,vtb=INT_MIN; } } } j++; } } } void enter() { cin>>n>>nho>>lon; for(int i=1;i<=n;i++) { cin>>a[i]; } sort(a+1,a+1+n); sub1(); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen("EVENTS.inp","r",stdin); // freopen("EVENTS.out","w",stdout); enter(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...