답안 #481899

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
481899 2021-10-22T07:44:21 Z Yazan_Alattar Table Tennis (info1cup20_tabletennis) C++14
9 / 100
3000 ms 17828 KB
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <utility>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 200007;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

vector <int> v;
int n, k, a[M];
map <int,int> cnt;

int solve(int sum)
{
    int ret = 0;
    for(int i = 1; i <= n + k; ++i) ++cnt[a[i]];
    for(int i = 1; i <= n; ++i){
        if(ret < n && cnt[sum - a[i]]){
            --cnt[sum - a[i]];
            --cnt[a[i]];
            ret += 2;
        }
    }
    return ret >= n;
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n + k; ++i) cin >> a[i];
    sort(a + 1, a + n + k + 1);
    bool res = 0;
    for(int i = 1; i <= k + 1; ++i){
        for(int j = n; j >= max(i, n - k - 1); --j){
            cnt.clear();
            res = solve(a[i] + a[j]);
            if(res) break;
        }
        if(res) break;
    }
    for(int i = 1; i <= n + k; ++i){
        if(cnt[a[i]]) --cnt[a[i]];
        else cout << a[i] << " ";
    }
    cout << endl;
    return 0;
}
// Don't forget special cases. (n = 1?)
// Look for the constraints. (Runtime array? overflow?)
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 460 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 1700 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 381 ms 17828 KB Output is correct
2 Correct 94 ms 10912 KB Output is correct
3 Incorrect 568 ms 16572 KB Unexpected end of file - int32 expected
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 127 ms 320 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 143 ms 528 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Execution timed out 3064 ms 16360 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Execution timed out 3085 ms 16392 KB Time limit exceeded
3 Halted 0 ms 0 KB -