# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
689602 | 2023-01-28T20:22:18 Z | LucaLucaM | Table Tennis (info1cup20_tabletennis) | C++17 | 156 ms | 4688 KB |
#include <bits/stdc++.h> using namespace std; /** trebuie sa alegem n din n + k numere astfel incat a[1] + a[n] = a[2] + a[n-1] = ... = a[n/2] + a[n/2+1] a[1] + a[n] = a[2] + a[n-1] a[n] - a[n-1] = a[2] - a[1] a[n-1] - a[n-2] = a[3] - a[2] ... a[n/2+1] - a[n/2] = a[n] - a[n-1] n*k + nlogn? **/ int a[150401]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; int m = n + k; for (int i=1; i<=m; i++) cin >> a[i]; for (int i=1; i<=k+1; i++) /// O(k) { /// incercam sa fie a[i] cel mai mic element , a[j] cel mai mare for (int j=m; m-j+i-1 <= k; j--) /// O(k*k) { int sum = a[i] + a[j]; int l=i, r=j; int cnt = 0; while (l < r) { while (l < r && a[l] + a[r] > sum) r--; while (l < r && a[l] + a[r] < sum) l++; if (a[l] + a[r] != sum) { cnt = -1; break; } cnt++; l++; } if (cnt >= n/2) { cnt = n / 2; vector<int>ans; int l=i, r=j; while (l < r && cnt--) { while (l < r && a[l] + a[r] > sum) r--; while (l < r && a[l] + a[r] < sum) l++; ans.push_back(a[l]); ans.push_back(a[r]); l++, r--; } for (int i=0; i<n; i+=2) cout << ans[i] << ' '; reverse(ans.begin(), ans.end()); for (int i=int(ans.size()) & 1; i<ans.size(); i+=2) cout << ans[i] << ' '; return 0; } } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 980 KB | Output is correct |
2 | Correct | 29 ms | 4688 KB | Output is correct |
3 | Correct | 28 ms | 4504 KB | Output is correct |
4 | Correct | 30 ms | 4620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 4424 KB | Output is correct |
2 | Correct | 29 ms | 4520 KB | Output is correct |
3 | Correct | 29 ms | 4516 KB | Output is correct |
4 | Correct | 28 ms | 4552 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 324 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 320 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 352 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 352 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 34 ms | 4592 KB | Output is correct |
3 | Correct | 44 ms | 4456 KB | Output is correct |
4 | Correct | 28 ms | 4532 KB | Output is correct |
5 | Correct | 27 ms | 4520 KB | Output is correct |
6 | Correct | 37 ms | 4484 KB | Output is correct |
7 | Correct | 29 ms | 4508 KB | Output is correct |
8 | Correct | 28 ms | 4436 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 56 ms | 4552 KB | Output is correct |
3 | Correct | 28 ms | 4472 KB | Output is correct |
4 | Correct | 45 ms | 4512 KB | Output is correct |
5 | Correct | 28 ms | 4412 KB | Output is correct |
6 | Correct | 156 ms | 4672 KB | Output is correct |
7 | Correct | 39 ms | 4552 KB | Output is correct |
8 | Correct | 28 ms | 4544 KB | Output is correct |