Submission #519625

#TimeUsernameProblemLanguageResultExecution timeMemory
519625aryan12Gap (APIO16_gap)C++17
30 / 100
49 ms3220 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; long long Solve1(long long N) { long long A[N]; long long L = 0, R = N - 1; long long valL = 0, valR = 1e18; while(L <= R) { MinMax(valL, valR, &valL, &valR); A[L++] = valL; A[R--] = valR; valL++; valR--; } long long ans = 0; for(long long i = 1; i < N; i++) { ans = max(ans, A[i] - A[i - 1]); } return ans; } long long Solve2(long long N) { vector<long long> A; long long l, r; long long mn, mx; MinMax(0, 1e18, &mn, &mx); A.push_back(mn); A.push_back(mx); long long store_mx = mx - 1; long long len = (mx - mn - 1) / (N - 1) + 1; l = mn, r = mx; while(l < r) { l = mn + 1; r = min(mn + len, store_mx); MinMax(l, r, &mn, &mx); if(mn == -1) { l = r + 1; if(r == store_mx) break; continue; } A.push_back(mn); A.push_back(mx); if(r == store_mx) { break; } } sort(A.begin(), A.end()); long long ans = 0; for(int i = 1; i < A.size(); i++) { ans = max(ans, A[i] - A[i - 1]); } return ans; } long long findGap(int T, int N) { if(T == 1) return Solve1(N); return Solve2(N); }

Compilation message (stderr)

gap.cpp: In function 'long long int Solve2(long long int)':
gap.cpp:50:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |  for(int i = 1; i < A.size(); i++) {
      |                 ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...