Submission #366225

#TimeUsernameProblemLanguageResultExecution timeMemory
366225Ahmad_HasanTable Tennis (info1cup20_tabletennis)C++17
72 / 100
3094 ms403232 KiB
#include <bits/stdc++.h> #define int long long /** |||||||||| ||||| ||||| |||||||||| ||||||||||||| ||||| ||||| ||||| |||| |||||| ||||| ||||| ||||| ||||||||||||||||| ||||||||||||||| |||||||||| ||||||||||||||||||| ||||||||||||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| |||||||||| AHMED;HASSAN;SAEED; */ using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,k; cin>>n>>k; vector<int>v(n+k); map<int,int >mp,mp2; int nn=n+k; for(int i=0;i<nn;i++){ cin>>v[i]; mp2[v[i]]=i+1; } vector<vector<pair<int,int> > >pos((k+10)*(k+10)); int cr=1; for(int i=0;i<nn&&i<k+2;i++){ for(int j=nn-1;j>=0&&(nn-1-j)<=k+2;j--){ if(!mp[v[i]+v[j]]){ mp[v[i]+v[j]]=cr++; } } } int mxi=0; for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){ for(int i=0;i<nn;i++){ int vl=mp2[(it->first)-v[i]]; if(vl>i+1){ pos[it->second].push_back({i,vl-1}); } } } /** for(int i=0;i<pos.size();i++){ for(int j=0;j<pos[i].size();j++){ cout<<pos[i][j].first<<'-'<<pos[i][j].second<<' '; } cout<<'\n'; }*/ for(int i=0;i<pos.size();i++) if(pos[i].size()>pos[mxi].size()) mxi=i; vector<int>ans; for(int i=0;i<pos[mxi].size()&&ans.size()<n;i++){ ans.push_back(v[pos[mxi][i].first]); ans.push_back(v[pos[mxi][i].second]); } sort(ans.begin(),ans.end()); for(int i=0;i<ans.size();i++) cout<<ans[i]<<' '; return 0; } /** 4 3 100000000000 200000000000 300000000000 400000000000 800000000000 1000000000000 2000000000000 */

Compilation message (stderr)

tabletennis.cpp: In function 'int32_t main()':
tabletennis.cpp:57:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(int i=0;i<pos.size();i++)
      |                 ~^~~~~~~~~~~
tabletennis.cpp:61:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(int i=0;i<pos[mxi].size()&&ans.size()<n;i++){
      |                 ~^~~~~~~~~~~~~~~~
tabletennis.cpp:61:46: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   61 |     for(int i=0;i<pos[mxi].size()&&ans.size()<n;i++){
      |                                    ~~~~~~~~~~^~
tabletennis.cpp:67:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     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...