Submission #685672

#TimeUsernameProblemLanguageResultExecution timeMemory
685672heeheeheehaawTable Tennis (info1cup20_tabletennis)C++17
0 / 100
101 ms8012 KiB
#include <iostream> #include <vector> #include <algorithm> #include <map> using namespace std; int n, k; int v[200005]; void afisare(vector<int> rez) { sort(rez.begin(), rez.end()); cout<<v[rez[0]]; for(int i = 1; i < rez.size(); i++) cout<<" "<<v[rez[i]]; return; } vector<int> possible(int sum) { vector<int> rez; int dr = n + k; for(int i = 1; i <= n; i++) { while(v[i] + v[dr] > sum) dr--; if(i >= dr) break; if(v[i] + v[dr] < sum) { rez.clear(); return rez; } rez.push_back(i); rez.push_back(dr); dr--; } if((int)rez.size() == n) return rez; rez.clear(); return rez; } void solve1() { for(int i = 1; i <= n + k; i++) for(int j = i + 1; j <= n + k; j++) { vector<int> rez = possible(v[i] + v[j]); if(rez.size() != 0) { afisare(rez); return; } } return; } void solve2() { map<int, int> mp; for(int i = 1; i <= k; i++) for(int j = n; j <= n + k; j++) mp[v[i] + v[j]]++; for(auto it: mp) { if(it.second >= k) { vector<int> rez = possible(it.first); if(rez.size() != 0) { afisare(rez); return; } } } return; } int main() { cin>>n>>k; for(int i = 1; i <= n + k; i++) cin>>v[i]; if(n + k <= 4 * k) solve1(); else solve2(); return 0; }

Compilation message (stderr)

tabletennis.cpp: In function 'void afisare(std::vector<int>)':
tabletennis.cpp:15:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i = 1; i < rez.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...