Submission #536250

#TimeUsernameProblemLanguageResultExecution timeMemory
536250DJ035Gap (APIO16_gap)C++17
88.67 / 100
56 ms1992 KiB
#include "gap.h" #include <bits/stdc++.h> long long findGap(int T, int N) { long long arr[111111]; long long mn, mx; long long tmp; long long maximum; long long high=1e18, low=0; if(T==1) { for(int i=1;i<=N/2;i++) { MinMax(low,high,&mn,&mx); arr[i]=mn; arr[N-i+1]=mx; low=mn+1; high=mx-1; } if(N%2==1) { MinMax(low,high,&mn,&mx); arr[N/2+1]=mn; } long long answer=0; for(int i=2;i<=N;i++) answer=std::max(answer,arr[i]-arr[i-1]); return answer; } else { long long answer=0; MinMax(low,high,&mn,&mx); tmp=mn; maximum=mx; long long sz; low=mn+1; high=mx-1; sz=(mx-mn+N-1)/N; high=low+sz; for(int i=0;i<N;i++) { MinMax(low,high,&mn,&mx); low+=sz; high+=sz; if(mn==-1) continue; answer=std::max(answer,mn-tmp); tmp=mx; } return answer; } }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:9:15: warning: variable 'maximum' set but not used [-Wunused-but-set-variable]
    9 |     long long maximum;
      |               ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...