# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
499882 | 2021-12-29T21:49:36 Z | jesus_coconut | Table Tennis (info1cup20_tabletennis) | C++17 | 3000 ms | 5152 KB |
#include <bits/stdc++.h> #define pb push_back #define all(a) begin(a), end(a) using namespace std; int n, k; vector<int> v; vector<int> dif; void load() { cin >> n >> k; v.resize(n + k); for (auto &it : v) cin >> it; } vector<int> ans; bool solve(int l, int r) { if (l >= r) return false; ans.clear(); ans.pb(v[l]); ans.pb(v[r]); while (l < r) { int cl = dif[l+1]; int cr = dif[r]; int pl = l, pr = r; while (cl != cr && l < r) { if (cl < cr) { l++; cl += dif[l+1]; } else { r--; cr += dif[r]; } } ++l; --r; if (l >= r) break; if (cl == cr) { ans.pb(v[l]); ans.pb(v[r]); } if (ans.size() == n) return true; } return false; } void solve() { for (int i = 0; i <= k; ++i) { for (int j = 0; j <= k - i; ++j) { if (solve(i, n + k - 1 - j)) { sort(all(ans)); for (auto &it: ans) cout << it << ' '; return; }; } } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); load(); sort(all(v)); dif.resize(size(v)); adjacent_difference(all(v), begin(dif)); solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 844 KB | Output is correct |
2 | Correct | 38 ms | 5136 KB | Output is correct |
3 | Correct | 32 ms | 5056 KB | Output is correct |
4 | Correct | 34 ms | 5112 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 3604 KB | Output is correct |
2 | Correct | 33 ms | 3664 KB | Output is correct |
3 | Correct | 33 ms | 3648 KB | Output is correct |
4 | Correct | 33 ms | 3648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 158 ms | 3652 KB | Output is correct |
3 | Correct | 37 ms | 5020 KB | Output is correct |
4 | Correct | 55 ms | 5056 KB | Output is correct |
5 | Correct | 35 ms | 5048 KB | Output is correct |
6 | Correct | 49 ms | 5152 KB | Output is correct |
7 | Correct | 53 ms | 5096 KB | Output is correct |
8 | Correct | 34 ms | 5100 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Execution timed out | 3078 ms | 1412 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |