Submission #745806

# Submission time Handle Problem Language Result Execution time Memory
745806 2023-05-21T08:04:43 Z vjudge1 Table Tennis (info1cup20_tabletennis) C++17
0 / 100
3000 ms 65836 KB
#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
vector<int> scores;
int n, k;

bool possible(int a, int b){
    int sum = scores[a] + scores[b];
    vector<int> square;
    for (int i=a; i<n+k; i++){
        if (scores[i] * 2 < sum && m[sum - scores[i]]){
            square.push_back(scores[i]);
        }
    }
    if (square.size() < n/2) return false;
    sort(square.begin(), square.end());
    for (int i=0; i<n/2; i++){
        cout << square[i] << " ";
    }
    for (int i=n/2-1; i>=0; i--){
        cout << sum - square[i] << " ";
    }
}

int main()
{
    cin >> n >> k;
    scores.resize(n+k);
    for (int i=0; i<n+k; i++){
        cin >> scores[i];
        m[scores[i]]++;
    }
    for (int i=0; i<=k; i++){
        for (int j=i+1; j<n+k; j++){
            if (possible(i, j)){
                return 0;
            }
        }
    }
}

Compilation message

tabletennis.cpp: In function 'bool possible(int, int)':
tabletennis.cpp:15:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |     if (square.size() < n/2) return false;
      |         ~~~~~~~~~~~~~~^~~~~
tabletennis.cpp:9:17: warning: control reaches end of non-void function [-Wreturn-type]
    9 |     vector<int> square;
      |                 ^~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 562 ms 65836 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3044 ms 1584 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3065 ms 27416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -