Submission #791899

# Submission time Handle Problem Language Result Execution time Memory
791899 2023-07-24T12:24:23 Z Cookie Table Tennis (info1cup20_tabletennis) C++14
0 / 100
3000 ms 12212 KB
#include<bits/stdc++.h>
#include<fstream>
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("avx2")
using namespace std;
//ifstream fin("FEEDING.INP");
//ofstream fout("FEEDING.OUT");
#define sz(a) (int)a.size()
#define int long long
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ll mxn = 150005, base = 972663749;
const ll mod = 911382323, mxv = 1e9 + 1;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rr(ll l, ll r){
    return(uniform_int_distribution<ll>(l, r)(rng));
}

int n, k;
ll a[mxn + 1];
vt<ll>seg;
int check(ll v, bool trace = 0){
    
    map<int, int>seen;
    int cnt = 0;
    for(int i = 1; i <= n + k; i++){
        if(seen.find(v - a[i]) != seen.end()){
            if(trace){
                seg.pb(a[i]); seg.pb(v - a[i]);
            }
            cnt++;
        }
        seen[a[i]] = 1;
    }
    return(cnt);
}
signed main()
{
     ios_base::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);
    while(1){
        int tol = rr(1, n + k - 1), tor = rr(tol + 1, n + k);
        if(check(tol + tor) >= n / 2){
            check(tol + tor, 1);
            break;
        }
    }
    sort(seg.begin(), seg.end());
    for(auto i: seg){
        cout << i << " ";
    }
    return(0);
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3044 ms 468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3042 ms 1876 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3053 ms 12212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3043 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3052 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3047 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3021 ms 220 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3062 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -