Submission #377598

#TimeUsernameProblemLanguageResultExecution timeMemory
377598keta_tsimakuridzeTable Tennis (info1cup20_tabletennis)C++14
100 / 100
522 ms46044 KiB
#include<bits/stdc++.h> #define f first #define int long long #define s second using namespace std; const int N=2e5+5,mod=1e9+7; int t,a[N],n,k; vector<int>v,Ans,ans; map<int,int>fix; string s; main(){ cin>>n>>k; n+=k; for(int i=1;i<=n;i++){ cin>>a[i]; } Ans.resize(n); if(n>=4*k) for(int i=1;i<=2*k;i++){ for(int j=n;j>=n-2*k+1;j--){ fix[a[i]+a[j]]++; if(fix[a[i]+a[j]]==k) v.push_back(a[i]+a[j]); } } else for(int i=0;i<=k;i++){ for(int j=n;j>=n-k+i;j--){ v.push_back(a[i+1]+a[j]); } } for(int i=0;i<v.size();i++){ int sum = v[i]; ans.clear(); int l=1,r=n; while(l<r) { if(a[l]+a[r]==sum){ ans.push_back(a[l]); ans.push_back(a[r]); l++; r--; } else if(a[l]+a[r]<sum) l++; else r--; } if(ans.size()>=n-k){ Ans=ans; } } sort(Ans.begin(),Ans.end()); for(int i=0;i<(n-k)/2;i++){ cout<<Ans[i]<<" "; } for(int i=(int)Ans.size()-(n-k)/2;i<=Ans.size()-1;i++){ cout<<Ans[i]<<" "; } }

Compilation message (stderr)

tabletennis.cpp:11:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main(){
      |      ^
tabletennis.cpp: In function 'int main()':
tabletennis.cpp:30:15: 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]
   30 |  for(int i=0;i<v.size();i++){
      |              ~^~~~~~~~~
tabletennis.cpp:44:16: 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]
   44 |   if(ans.size()>=n-k){
      |      ~~~~~~~~~~^~~~~
tabletennis.cpp:54:37: 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]
   54 |  for(int i=(int)Ans.size()-(n-k)/2;i<=Ans.size()-1;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...