# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
447547 | LucaIlie | Table Tennis (info1cup20_tabletennis) | C++17 | 80 ms | 3300 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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, elim, s, f, i, j;
scanf( "%d%d", &n, &k );
for ( i = 0; i < n + k; i++ )
scanf( "%d", &v[i] );
for ( i = 0; i < k + 1; i++ ) {
for ( j = n - 1 + i; j < n + k; j++ ) {
elim = j - i + 1 - n;
s = i;
f = j;
suma = v[s] + v[f];
ans[0] = v[s];
ans[n - 1] = v[f];
s++;
f--;
m = 1;
while ( s < f && elim >= 0 ) {
if ( v[s] + v[f] == suma ) {
ans[m] = v[s];
ans[n - 1 - m] = v[f];
m++;
s++;
f--;
} else if ( v[s] + v[f] < suma ) {
s++;
elim--;
} else {
f--;
elim--;
}
}
if ( m == n / 2 )
break;
}
if ( j < n + k )
break;
}
for ( i = 0; i < n; i++ )
printf( "%d ", ans[i] );
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |