Submission #313439

#TimeUsernameProblemLanguageResultExecution timeMemory
313439nandonathanielGap (APIO16_gap)C++14
0 / 100
74 ms1280 KiB
#include "gap.h" #include "bits/stdc++.h" using namespace std; long long findGap(int T, int N) { vector<long long> ujung; long long mn,mx; MinMax(0,1e18,&mn,&mx); //mn+1...mx-1 bagi N-1 segment //PHP ada 1 segment yang kosong //Gap maximumnya beda segment long long bagi=(mx-mn-1)/(N-1); int sisa=(mx-mn-1)%(N-1); long long ki=mn+1,last=mn,ujungka=mx,ans=0; for(int i=1;i<N;i++){ if(i<=sisa){ MinMax(ki,ki+bagi,&mn,&mx); ki+=(bagi+1); } else{ MinMax(ki,ki+bagi-1,&mn,&mx); ki+=bagi; } if(mn!=-1){ ans=max(ans,mn-last); last=mx; } } ans=max(ans,mx-last); return ans; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:14:28: warning: unused variable 'ujungka' [-Wunused-variable]
   14 |  long long ki=mn+1,last=mn,ujungka=mx,ans=0;
      |                            ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...