# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
367090 | 2021-02-16T08:19:07 Z | ritul_kr_singh | Watching (JOI13_watching) | C++17 | 1 ms | 384 KB |
//#pragma GCC optimize("Ofast,unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long #define sp << " " << #define nl << "\n" int n, p, q; int a[2000]; bool possible(int w){ vector<array<int, 2>> res = {{a[0], a[0]}}; for(int i=1; i<n; ++i){ if(res.back()[0] + w - 1 < a[i]){ res.push_back({a[i], a[i]}); }else res.back()[1] = a[i]; } int x = 0, y = 0; for(int i=0; i<res.size(); ++i){ if(i+1 < res.size() and res[i+1][1]-res[i][0]+1<=2*w){ y += 1; i += 1; }else x += 1; } if(y > q){ x += 2*(y-q); y = q; } return x <= p; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> p >> q; for(int i=0; i<n; ++i) cin >> a[i]; sort(a, a+n); int low = 1, high = 1e9; while(low < high){ int mid = (low+high)/2; if(possible(mid)) high = mid; else low = mid+1; } cout << low nl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Incorrect | 1 ms | 384 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |