제출 #523400

#제출 시각아이디문제언어결과실행 시간메모리
523400Ahmed2meTable Tennis (info1cup20_tabletennis)C++17
100 / 100
366 ms33792 KiB
#include <bits/stdc++.h> using namespace std; int n,m; int a[200020]; int main() { scanf("%d",&n);scanf("%d",&m);map<int,int>mp; for(int i=1;i<=n+m;i++){scanf("%d",&a[i]);} if(n <= 4 * m) { for(int i = 1; i <= n + m; ++i){ for(int j = i + 1; j <= n + m; ++j){ { int sum=a[i]+a[j]; int i=1,j=n+m; vector<int>ans; int counter=false; while(i<j) { if(counter>=n){break;} if(a[i]+a[j]==sum){counter+=2;ans.push_back(a[i]);ans.push_back(a[j]);i++;j--;} else if(a[i]+a[j]>sum){j--;} else if(a[i]+a[j]<sum){i++;} } if(counter==n) { sort(ans.begin(),ans.end()); for(int i=0;i<ans.size();i++){printf("%d%c",ans[i],' ');} return 0; } } } } return 0; } for(int i=1;i<=min(n,2*m);i++) { for(int j=max(1,(n-m+1));j<=n+m;j++) { mp[(a[i]+a[j])]++; } } for(auto I:mp) { if(I.second<m){continue;} int sum=I.first; int i=1,j=n+m; vector<int>ans; int counter=false; while(i<j) { if(counter>=n){break;} if(a[i]+a[j]==sum){counter+=2;ans.push_back(a[i]);ans.push_back(a[j]);i++;j--;} else if(a[i]+a[j]>sum){j--;} else if(a[i]+a[j]<sum){i++;} } if(counter==n) { sort(ans.begin(),ans.end()); for(int i=0;i<ans.size();i++){printf("%d%c",ans[i],' ');} return 0; } } return 0; }

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

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int i=0;i<ans.size();i++){printf("%d%c",ans[i],' ');}
      |                     ~^~~~~~~~~~~
tabletennis.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |         for(int i=0;i<ans.size();i++){printf("%d%c",ans[i],' ');}
      |                     ~^~~~~~~~~~~
tabletennis.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d",&n);scanf("%d",&m);map<int,int>mp;
      |     ~~~~~^~~~~~~~~
tabletennis.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d",&n);scanf("%d",&m);map<int,int>mp;
      |                    ~~~~~^~~~~~~~~
tabletennis.cpp:11:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for(int i=1;i<=n+m;i++){scanf("%d",&a[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...