Submission #721418

#TimeUsernameProblemLanguageResultExecution timeMemory
721418FatihSolakGap (APIO16_gap)C++17
100 / 100
51 ms1872 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; const long long INF = 1e18; long long findGap(int t, int n) { if(t == 1){ int cnt = 0; vector<long long> v(n); long long l = -1,r=INF+1; while(cnt <= n-1-cnt){ MinMax(l+1,r-1,&v[cnt],&v[n-1-cnt]); l = v[cnt]; r = v[n-1-cnt]; cnt++; } long long ans = 0; for(int i = 1;i<n;i++){ ans = max(ans,v[i]-v[i-1]); } return ans; } if(t == 2){ long long x,y; MinMax(0,INF,&x,&y); long long ans = (y-x)/(n-1); long long num = x; long long last = x; while(num != y){ long long tmp1,tmp2; MinMax(num+1,num+ans,&tmp1,&tmp2); if(tmp1 == -1){ num += ans; } else{ ans = max(ans,tmp1 - last); num = tmp2; last = tmp2; } } return ans; } }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...