제출 #518358

#제출 시각아이디문제언어결과실행 시간메모리
518358Ronin13Table Tennis (info1cup20_tabletennis)C++14
100 / 100
417 ms43616 KiB
#include<bits/stdc++.h> #define ll long long #define ull unsigned ll #define pb push_back #define f first #define s second #define pii pair<int,int> #define pll pair<ll,ll> #define epb emplace_back #define inf 1e9+1 #define linf 1e18+11 using namespace std; map<ll,int>used; int main(){ int n;cin>>n; int k;cin>>k; n+=k; int a[n+1]; for(int i=1;i<=n;i++)cin>>a[i]; vector<int>vec; if(n>=4*k){ for(int i=1;i<=2*k+1;i++){ for(int j=n;j>=n-2*k;j--){ int x=a[i]+a[j]; used[x]++; if(used[x]==k)vec.pb(x); } } } else{ for(int i=1;i<=k+1;i++){ for(int j=n;j>=n-k;j--){ int x=a[i]+a[j]; vec.pb(x); } } } for(int to:vec){ int l=1,r=n; vector<int>ans; while(l<r){ if(ans.size()==(n-k))break; if(a[l]+a[r]==to){ ans.pb(a[l]); ans.pb(a[r]); l++; r--; continue; } if(a[l]+a[r]>to){ r--; continue; } l++; } if(ans.size()==(n-k)){ sort(ans.begin(),ans.end()); for(int x:ans)cout<<x<<' '; return 0; } ans.clear(); } }

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

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