Submission #987384

#TimeUsernameProblemLanguageResultExecution timeMemory
987384Zbyszek99Table Tennis (info1cup20_tabletennis)C++17
63 / 100
36 ms4684 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define ff first #define ss second #define pb push_back #define rep(i, b) for(int i = 0; i < (b); ++i) #define rep2(i,a,b) for(int i = a; i <= (b); ++i) #define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c) #define count_bits(x) __builtin_popcountll((x)) #define all(x) (x).begin(),(x).end() #define size(x) (int)(x).size() #define forall(it,x) for(auto& it:(x)) using namespace std; //mt19937 mt;void random(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());} //ll rand(ll a, ll b) {return a + (mt() % (b-a+1));} const int INF = 1e9+50; const ll INF_L = 1e18+40; const ll MOD = 1e9+7; int tab[150400]; void solve() { int n,k; cin >> n >> k; rep(i,n+k) { cin >> tab[i]; } sort(tab,tab+(n+k)); for(int i = 0; i <= k; i++) { for(int j = n+k-1; j >= n-1; j--) { // cout << i << " " << j << "\n"; int r = i+1; int l = j-1; int w = tab[i] + tab[j]; int how_many_pairs = 1; while(l >= r) { while(tab[r] + tab[l] < w && l >= r) { r++; } while(tab[r] + tab[l] > w && l >= r) { l--; } if(l >= r) { how_many_pairs++; r++; l--; } } // cout << i << " " << j << "\n"; if(how_many_pairs >= n/2) { vector<int> wyn = {tab[i],tab[j]}; r = i+1; l = j-1; while(l >= r) { while(tab[r] + tab[l] < w && l >= r) { r++; } while(tab[r] + tab[l] > w && l >= r) { l--; } if(l >= r) { if(size(wyn) != n) { wyn.pb(tab[r]);wyn.pb(tab[l]); } r++; l--; } } sort(all(wyn)); rep(i,n) cout << wyn[i] << " "; return; } } } } int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); // random(); int t = 1; // cin >> t; while(t--) solve(); }
#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...