제출 #342636

#제출 시각아이디문제언어결과실행 시간메모리
342636ogibogi2004Table Tennis (info1cup20_tabletennis)C++14
100 / 100
371 ms34016 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN=200002; int n,k; int a[MAXN]; bool found=0; map<int,int> mp; void check(int s) { vector<int>v1,v2; int l=1,r=n+k; while(l<r) { if(v1.size()+v2.size()==n)break; if(a[l]+a[r]==s) { v1.push_back(a[l]); v2.push_back(a[r]); ++l;--r; } else { if(a[l]+a[r]>s) { --r; } else ++l; } } if(v1.size()+v2.size()<n)return; reverse(v2.begin(),v2.end()); found=1; for(auto xd:v1)cout<<xd<<" "; for(auto xd:v2)cout<<xd<<" "; cout<<"\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin>>n>>k; for(int i=1;i<=n+k;++i) { cin>>a[i]; } for(int i=1;i<=2*k;++i) { for(int j=n-k;j<=n+k;++j) { ++mp[a[i]+a[j]]; } } for(auto xd:mp) { if(xd.second<k)continue; check(xd.first); if(found)return 0; } if(n>MAXN/2)assert(false); for(auto xd:mp) { check(xd.first); if(found)return 0; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

tabletennis.cpp: In function 'void check(int)':
tabletennis.cpp:14:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   14 |   if(v1.size()+v2.size()==n)break;
      |      ~~~~~~~~~~~~~~~~~~~^~~
tabletennis.cpp:30:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |  if(v1.size()+v2.size()<n)return;
      |     ~~~~~~~~~~~~~~~~~~~^~
#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...