제출 #667586

#제출 시각아이디문제언어결과실행 시간메모리
667586Hacv16Table Tennis (info1cup20_tabletennis)C++17
0 / 100
25 ms3084 KiB
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int MAX = 2e6 + 50;
const int INF = 0x3f3f3f3f;

int n, k, tot, ans = -1;
vector<ll> v;

bool solve(ll l, ll r, ll sum, bool flag){
    ll id = 0;
    bool alreadyBad = flag;

    for(int i = l + 1, j = r - 1; i < j; i++, j--){
        if(v[i] + v[j] != sum){
            if(alreadyBad) return false;
            alreadyBad = true;

            int di = v[i + 1] - v[i];
            int dj = v[j] - v[j - 1];

            if(di > dj) id = i++;
            else id = j--;
        }
    }

    ans = id;
    return true;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> k;

    tot = n + k;

    for(int i = 0; i < tot; i++){
        ll x; cin >> x;
        v.push_back(x);
    }

    vector<ll> trash;

    solve(0, tot - 1, v[0] + v[tot - 1], false);
    if(solve(0, tot - 2, v[0] + v[tot - 2], true)) ans = tot - 1;
    if(solve(1, tot - 1, v[0] + v[tot - 1], true)) ans = 0;

    for(int i = 0; i < tot; i++){
        if(i == ans) continue;
        cout << v[i] << ' ';
    }

    cout << '\n';

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...