Submission #481818

# Submission time Handle Problem Language Result Execution time Memory
481818 2021-10-22T01:15:28 Z Yazan_Alattar Table Tennis (info1cup20_tabletennis) C++14
9 / 100
3000 ms 4540 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];
bool vist[M];

int solve(int sum)
{
    int l = 1, r = n + k;
    while(l < r){
        if(a[l] + a[r] == sum){
            ++l;
            --r;
        }
        else if(a[l] + a[r] > sum){
            v.pb(r);
            --r;
        }
        else{
            v.pb(l);
            ++l;
        }
    }
    if(l == r) v.pb(l);
    return ((int)v.size() == k);
}

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){
            res = solve(a[i] + a[j]);
            if(res) break;
            else v.clear();
        }
        if(res) break;
    }
    for(auto i : v) vist[i] = 1;
    for(int i = 1; i <= n + k; ++i) if(!vist[i]) cout << a[i] << " ";
    cout << endl;
    return 0;
}
// Don't forget special cases. (n = 1?)
// Look for the constraints. (Runtime array? overflow?)
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output does not have symmetry property
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 588 KB Output is correct
2 Incorrect 45 ms 3060 KB Output does not have symmetry property
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 3100 KB Output is correct
2 Correct 29 ms 3780 KB Output is correct
3 Incorrect 32 ms 4540 KB Output does not have symmetry property
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 4 ms 204 KB Output does not have symmetry property
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 2 ms 332 KB Output does not have symmetry property
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 407 ms 3008 KB Output does not have symmetry property
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Execution timed out 3057 ms 1996 KB Time limit exceeded
3 Halted 0 ms 0 KB -