Submission #710297

#TimeUsernameProblemLanguageResultExecution timeMemory
710297sharaelongGap (APIO16_gap)C++17
0 / 100
55 ms3192 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; ll findGap(int T, int n) { ll mn, mx; ll gap = 0; pair<ll, ll> range = { 0, 1000000000000000000ll }; vector<ll> arr; if (T == 1) { for (int i=0; i<(n+1)/2; ++i) { MinMax(range.first, range.second, &mn, &mx); arr.push_back(mn); arr.push_back(mx); range = { mn+1, mx-1 }; } } else { MinMax(range.first, range.second, &mn, &mx); arr.push_back(mn); arr.push_back(mx); ll d = (mx-mn-1) / (n-1); ll mn_cpy = mn, mx_cpy = mx; // cout << d << ' ' << mn << ' ' << mx << endl; for (int i=0; i<n-1; ++i) { // cout << mn_cpy+1 + (d+1)*i << ' ' << mn_cpy + (d+1)*(i+1) << endl; MinMax(mn_cpy+1 + (d+1)*i, mn_cpy + (d+1)*(i+1), &mn, &mx); if (mn != -1) { arr.push_back(mn); arr.push_back(mx); } } } sort(arr.begin(), arr.end()); for (int i=0; i+1<n; ++i) gap = max(gap, arr[i+1]-arr[i]); return gap; }

Compilation message (stderr)

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:26:25: warning: unused variable 'mx_cpy' [-Wunused-variable]
   26 |         ll mn_cpy = mn, mx_cpy = mx;
      |                         ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...