Submission #551463

#TimeUsernameProblemLanguageResultExecution timeMemory
551463nafis_shifatTable Tennis (info1cup20_tabletennis)C++17
49 / 100
62 ms11900 KiB
#include<bits/stdc++.h> #define ll long long #define pii pair<int,int> using namespace std; const int mxn=1e5+5; const int inf=1e9; int n, k; int a[mxn]; map<int, int> mp; bool check(int tot) { int pair = 0; for(int i = 1; i <= n + k; i++) { if(mp.count(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(mp.count(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]; mp[a[i]] = 1; } for(int i = 1; i <= min(n + k, k + 2); i++) { for(int j = n + k; j >= max(1, n - 2); 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...