Submission #551488

#TimeUsernameProblemLanguageResultExecution timeMemory
551488nafis_shifatTable Tennis (info1cup20_tabletennis)C++17
87 / 100
3079 ms548460 KiB
#include<bits/stdc++.h> #define ll long long #define pii pair<int,int> using namespace std; const int mxn=2e5+5; const int inf=1e9; int n, k; int a[mxn]; bool cnt[2 * inf + 1]; bool check(int tot) { int pair = 0; for(int i = 1; i <= n + k; i++) { if(tot - a[i] >= 0 && cnt[tot - a[i]]) pair++; } return pair >= n; } void print(int tot) { int pair = 0; vector<int> v; for(int i = 1; i <= n + k && pair < n; i++) { if(tot - a[i] >= 0 && cnt[tot - a[i]]) { pair += 2; v.push_back(a[i]); v.push_back(tot - a[i]); } } sort(v.begin(), v.end()); for(int i : v) cout<<i<<" "; cout<<endl; } int main() { cin >> n >> k; for(int i = 1; i <= n + k; i++) { cin >> a[i]; cnt[a[i]] = 1; } for(int i = 1; i <= min(n + k, k + 2); i++) { for(int j = n + k; j >= max(1, n - 3 + i); j--) { if(check(a[i] + a[j])) { print(a[i] + a[j]); 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...