# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
447535 | 2021-07-26T16:52:44 Z | LucaIlie | Table Tennis (info1cup20_tabletennis) | C++17 | 44 ms | 2928 KB |
#include <stdio.h> #include <algorithm> #include <map> #define MAX_N 150000 #define MAX_K 400 int v[MAX_N + MAX_K], sume[(2 * MAX_K + 1) * (2 * MAX_K + 1)], ans[MAX_N]; int main() { int n, k, m, suma, s, f, i, j, l; scanf( "%d%d", &n, &k ); for ( i = 0; i < n + k; i++ ) scanf( "%d", &v[i] ); m = 0; for ( i = 0; i < 2 * k + 1 && i < n + k; i++ ) { for ( j = n + k - (2 * k + 1) > 0 ? n + k - (2 * k + 1) : 0; j < n + k; j++ ) { if ( i != j ) { sume[m] = v[i] + v[j]; m++; } } } std::sort( sume, sume + m ); i = 0; while ( i < m ) { j = i + 1; while ( j < m && sume[i] == sume[j] ) j++; if ( j - i > k ) { suma = sume[i]; s = 0; f = n + k - 1; l = 0; while ( s < f && l < n / 2 ) { if ( v[s] + v[f] == suma ) { ans[l] = v[s]; ans[n - 1 - l] = v[f]; s++; f--; l++; } else if ( v[s] + v[f] < suma ) s++; else f--; } if ( l == n / 2 ) break; } i = j; } for ( i = 0; i < n; i++ ) printf( "%d ", ans[i] ); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 600 KB | Output is correct |
2 | Correct | 39 ms | 2888 KB | Output is correct |
3 | Correct | 44 ms | 2800 KB | Output is correct |
4 | Correct | 38 ms | 2876 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 2868 KB | Output is correct |
2 | Correct | 38 ms | 2892 KB | Output is correct |
3 | Correct | 38 ms | 2928 KB | Output is correct |
4 | Correct | 38 ms | 2904 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 332 KB | Output not subsequence of input |
2 | Halted | 0 ms | 0 KB | - |
# | 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 | Incorrect | 0 ms | 204 KB | Output not subsequence of input |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Output not subsequence of input |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Output not subsequence of input |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 972 KB | Output not subsequence of input |
2 | Halted | 0 ms | 0 KB | - |