# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
499891 | 2021-12-29T22:31:21 Z | jesus_coconut | Table Tennis (info1cup20_tabletennis) | C++17 | 3000 ms | 57596 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; void load() { cin >> n >> k; v.resize(n + k); for (auto &it : v) cin >> it; } vector<int> ans; bool solve(int suma) { ans.clear(); int l = 0, r = n + k - 1; int cnt = 0; while (l < r) { if (v[l] + v[r] == suma) { ans.pb(v[l]); ans.pb(v[r]); if (size(ans) == n) return true; ++l; --r; } else if (v[l] + v[r] < suma) { ++l; if (++cnt < k) return false; } else { --r; if (++cnt > k) return false; } } return false; } set<int> bio; void solve() { while (true) { int i = rand() % n; int j = n + k - 1 - i - (rand() % (k + 1)); if (j < 0 || bio.count(v[i] + v[j])) continue; bio.insert(v[i] + v[j]); if (solve(v[i] + v[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)); solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3075 ms | 204 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 744 KB | Output is correct |
2 | Execution timed out | 3098 ms | 1412 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 3008 KB | Output is correct |
2 | Correct | 34 ms | 3076 KB | Output is correct |
3 | Execution timed out | 3050 ms | 1036 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Execution timed out | 3067 ms | 596 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Execution timed out | 3071 ms | 332 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Execution timed out | 3061 ms | 6360 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Execution timed out | 3085 ms | 57596 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |