Submission #667626

#TimeUsernameProblemLanguageResultExecution timeMemory
667626vh50Table Tennis (info1cup20_tabletennis)C++17
0 / 100
3090 ms13904 KiB
#include <bits/stdc++.h> #define int long long #define endl "\n" using namespace std; vector <int> v, sp, resp; map <int, int> mm; int n, k, val; int test(int s) { int c = 0; for(auto i : v) { if(mm.find(s - i) != mm.end()) c++; } if(c < n) return 0; return 1; } main() { cin >> n >> k; int a1 = 1e9, a2 = -1, mn; for(int i = 0; i < n + k; i++) {int aux; cin >> aux; v.push_back(aux); mm[aux] = 1; a1 = min(a1, aux); a2 = max(a2, aux); mn = a1 + a2;} sort(v.begin(), v.end()); for(int i = 0; i < n + k; i++) { if(i == 0) sp.push_back(v[i]); else sp.push_back(sp[i - 1] + v[i]); } int sss = 0; mn = v[0] + v[n - 1]; int ini = max(mn, (2LL * sp[n - 1])/n); mn = v[n + k - 1] + v[k]; int fim = min(mn, (2LL * (sp[n + k - 1] - sp[k - 1]))/n); for(int i = ini; i <= fim; i++) { if(test(i) && !sss) { int c = 0; for(auto j : v) { if(c == n) break; if(mm.find(i - j) != mm.end()) { sss = 1; c+=2; resp.push_back(j); resp.push_back(i - j); } } } } sort(resp.begin(), resp.end()); for(auto i : resp) cout << i << " "; }

Compilation message (stderr)

tabletennis.cpp:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   18 | main()
      | ^~~~
#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...