Submission #364055

#TimeUsernameProblemLanguageResultExecution timeMemory
364055stefdascaTable Tennis (info1cup20_tabletennis)C++14
100 / 100
714 ms160016 KiB
#include<bits/stdc++.h> #define god dimasi5eks #pragma GCC optimize("Ofast") #define fi first #define se second #define pb push_back #define pf push_front #define mod 1000000007 #define dancila 3.14159265359 #define eps 1e-9 // #define fisier 1 using namespace std; typedef long long ll; int n, k, skills[200002]; unordered_map<int, int> frq; bitset<2000000002>vv; int main() { #ifdef fisier ifstream f("input.in"); ofstream g("output.out"); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> k; for(int i = 1; i <= n+k; ++i) cin >> skills[i]; int smm = 0; for(int i = 1; i <= k+1; ++i) for(int j = n - (i-1); j <= min(n+k, n+k+k - (i-1)); ++j) { if(i >= j) continue; frq[skills[i] + skills[j]]++; vv[skills[i] + skills[j]] = 1; if(frq[skills[i] + skills[j]] == n/2) { smm = skills[i] + skills[j]; break; } } for(int i = k+2; i <= min(20000, n/2+k); ++i) if(!smm) for(int j = n - (i-1); j <= min(n+k, n+k+k - (i-1)); ++j) { if(i >= j) continue; if(vv[skills[i] + skills[j]]) { if(frq[skills[i] + skills[j]] + (n/2+k) - i + 1 < n/2) vv[skills[i] + skills[j]] = 0; else { ++frq[skills[i] + skills[j]]; if(frq[skills[i] + skills[j]] == n/2) { smm = skills[i] + skills[j]; break; } } } } if(!smm) { unordered_map<int, int> ::iterator it; for(it = frq.begin(); it != frq.end(); ++it) if(smm == 0) smm = it -> first; else if(it -> second > frq[smm]) smm = it -> first; } int Rp = n+k; vector<int> ans; for(int i = 1; i <= n+k; ++i) { while(Rp > 0 && skills[i] + skills[Rp] > smm) --Rp; if(Rp > i && skills[i] + skills[Rp] == smm) { ans.pb(skills[Rp]); ans.pb(skills[i]); --Rp; } if(ans.size() == n) break; } sort(ans.begin(), ans.end()); for(int i = 0; i < ans.size(); ++i) cout << ans[i] << " "; return 0; }

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:93:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   93 |         if(ans.size() == n)
      |            ~~~~~~~~~~~^~~~
tabletennis.cpp:97:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   97 |     for(int i = 0; i < ans.size(); ++i)
      |                    ~~^~~~~~~~~~~~
#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...