# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
50994 | 2018-06-15T13:58:01 Z | alenam0161 | Gap (APIO16_gap) | C++17 | 0 ms | 0 KB |
#include "gap.h" #include <iostream> #include <algorithm> #include <vector> using namespace std; long long findGap(int T, int N) { if (N == 0)return 0; long long ans = 0; long long inf = 1e18 + 1; long long fi=long long(-1); long long se=long long(inf); vector<long long> a, b; while (true) { MinMax(fi, se, &fi, &se); if(fi!=-1) a.push_back(fi); if(se!=-1) b.push_back(se); if (fi == -1 || se == -1)break; fi++; se--; if (fi >= se)break; } for (int i = b.size() - 1; i >= 0; i--)a.push_back(b[i]); for (int i = 1; i < a.size(); ++i) { ans = max(ans, a[i] - a[i - 1]); } return ans; }