Submission #744935

#TimeUsernameProblemLanguageResultExecution timeMemory
744935amirhoseinfar1385Gap (APIO16_gap)C++17
30 / 100
42 ms1872 KiB
#include<bits/stdc++.h> #include "gap.h" using namespace std; long long findGap(int T, int N) { if(T==1){ vector<long long>all(N); long long mn=-1,mx=((long long)1e18+5),fmn=0,fmx=0; //cout<<mx<<"\n"; int last=N-1,first=0; while(last>=first){ MinMax(mn+1,mx-1,&fmn,&fmx); //cout<<first<<" "<<last<<" "<<mn+1<<" "<<mx-1<<" "<<fmn<<" "<<fmx<<'\n'; mn=fmn; mx=fmx; all[last]=mx; all[first]=mn; last--; first++; } long long res=0; for(int i=1;i<N;i++){ // cout<<all[i]<<" "<<all[i-1]<<'\n'; res=max(res,all[i]-all[i-1]); } return res; } else{ return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...