Submission #486851

# Submission time Handle Problem Language Result Execution time Memory
486851 2021-11-13T01:37:45 Z couplefire Table Tennis (info1cup20_tabletennis) C++17
11 / 100
276 ms 29884 KB
#include <bits/stdc++.h>
using namespace std;

int n, k, m, arr[200405];

void check(int sum){
    if(sum%2==1) return;
    sum /= 2;
    vector<int> res;
    for(int l = 0, r = m-1; l<r;){
        if(arr[l]+arr[r]==2*sum) res.push_back(arr[l]), res.push_back(arr[r]), ++l, --r;
        else if(sum-arr[l]>arr[r]-sum) ++l;
        else --r;
    }
    while((int)res.size()>n) res.pop_back(), res.pop_back();
    if((int)res.size()<n) return;
    sort(res.begin(), res.end());
    for(auto x : res)
        cout << x << ' ';
    cout << '\n'; exit(0);
}

int main(){
    // freopen("a.in", "r", stdin);
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> k; m = n+k;
    for(int i = 0; i<m; ++i)
        cin >> arr[i];
    sort(arr, arr+m);
    vector<int> todo;
    if(m<4*k){
        for(int i = 0; i<m; ++i)
            for(int j = i+1; j<m; ++j)
                todo.push_back(arr[i]+arr[j]);
        sort(todo.begin(), todo.end());
        todo.erase(unique(todo.begin(), todo.end()), todo.end());
    } else{
        map<int, int> cnt;
        for(int i = 0; i<2*k; ++i)
            for(int j = 0; j<2*k; ++j)
                cnt[arr[i]+arr[m-1-j]]++;
        for(auto [x, y] : cnt)
            if(y>=k) todo.push_back(x);
    }
    for(auto x : todo)
        check(x);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 892 KB Output is correct
2 Correct 44 ms 4528 KB Output is correct
3 Correct 34 ms 4504 KB Output is correct
4 Incorrect 20 ms 2252 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Correct 35 ms 4480 KB Output is correct
2 Correct 34 ms 4600 KB Output is correct
3 Incorrect 20 ms 2508 KB Unexpected end of file - int32 expected
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Incorrect 1 ms 332 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 976 KB Output is correct
2 Incorrect 276 ms 29884 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -