Submission #631530

#TimeUsernameProblemLanguageResultExecution timeMemory
631530TranGiaHuy1508Gap (APIO16_gap)C++17
30 / 100
66 ms2052 KiB
#include <bits/stdc++.h> using namespace std; #include "gap.h" using ll = long long; ll findGap(int T, int N){ if (T == 1){ ll mn, mx; vector<ll> L, R; ll lb = -1, rb = (ll)1e18 + 1; while (N > 0 && lb + 1 <= rb - 1){ MinMax(lb + 1, rb - 1, &mn, &mx); if (mn < 0) break; L.push_back(mn); R.push_back(mx); N--; if (mn != mx) N--; lb = mn; rb = mx; } ll res = 0; for (int i = 1; i < (int)L.size(); i++){ res = max(res, abs(L[i] - L[i-1])); } for (int i = 1; i < (int)R.size(); i++){ res = max(res, abs(R[i] - R[i-1])); } res = max(res, abs(R.back() - L.back())); return res; } return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...