Submission #976586

#TimeUsernameProblemLanguageResultExecution timeMemory
976586IsamGap (APIO16_gap)C++17
30 / 100
42 ms3868 KiB
#include "gap.h" #include<bits/stdc++.h> using namespace std; long long findGap(int T, int N){ long long mn, mx, ans = -((long long)1E18 + 7); vector<long long> a(N+1, 0ll); MinMax(0ll, (long long)1E18, &mn, &mx); a[1] = mn, a[N] = mx; if(T == 1 || N <= 10){ for(register int i = 2; i <= N/2 + (N & 1); ++i){ long long l = a[i-1], r = a[N - (i-1) + 1]; MinMax(l+1, r-1, &mn, &mx); // called by reference a[i] = mn, a[N - i + 1] = mx; } for(register int i = 2; i <= N; ++i) ans = max(ans, a[i] - a[i-1]); return ans; } long long blo = (mx - mn + N - 2) / (N - 1); int pmn{mn}, pmx{mx}; for(long long j = a[1]; j <= a[N]; j += blo){ MinMax(j + 1, j + blo, &mn, &mx); if(mn == -1) continue; ans = max(ans, mn - pmx); pmx = mx, pmn = mn; } return ans; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:17:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |   for(register int i = 2; i <= N/2 + (N & 1); ++i){
      |                    ^
gap.cpp:27:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   27 |   for(register int i = 2; i <= N; ++i) ans = max(ans, a[i] - a[i-1]);
      |                    ^
gap.cpp:35:11: warning: narrowing conversion of 'mn' from 'long long int' to 'int' [-Wnarrowing]
   35 |   int pmn{mn}, pmx{mx};
      |           ^~
gap.cpp:35:20: warning: narrowing conversion of 'mx' from 'long long int' to 'int' [-Wnarrowing]
   35 |   int pmn{mn}, pmx{mx};
      |                    ^~
gap.cpp:35:7: warning: variable 'pmn' set but not used [-Wunused-but-set-variable]
   35 |   int pmn{mn}, pmx{mx};
      |       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...