Submission #447520

# Submission time Handle Problem Language Result Execution time Memory
447520 2021-07-26T16:06:23 Z LucaIlie Table Tennis (info1cup20_tabletennis) C++17
0 / 100
77 ms 1088 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], res[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 = i + (n + k - 1 - j);
            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 && m < n / 2 && elim < k && elim + (f - s + 1) >= k ) {
                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 && elim == k ) {
                for ( m = 0; m < n; m++ )
                    res[m] = ans[m];
                break;
            }
        }
        if ( j < n + k )
            break;
    }

    for ( i = 0; i < n; i++ )
        printf( "%d ", res[i] );

    return 0;
}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf( "%d%d", &n, &k );
      |     ~~~~~^~~~~~~~~~~~~~~~~~
tabletennis.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf( "%d", &v[i] );
      |         ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output not subsequence of input
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 460 KB Output not subsequence of input
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 1088 KB Output not subsequence of input
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 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 0 ms 204 KB Output not subsequence of input
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output not subsequence of input
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 272 KB Output not subsequence of input
2 Halted 0 ms 0 KB -