제출 #728707

#제출 시각아이디문제언어결과실행 시간메모리
728707MilosMilutinovicTable Tennis (info1cup20_tabletennis)C++14
100 / 100
1126 ms5600 KiB
#include <bits/stdc++.h> using namespace std; int n,k,a[305005]; bool solve(int x) { int p=n+k,c=0; vector<int> ans; for(int i=1;i<=n+k;i++) { while(p>i&&a[i]+a[p]>x) p--; if(p>i&&a[i]+a[p]==x) { ans.push_back(a[i]); ans.push_back(a[p]); c++,p--; } } if(c>=n/2) { sort(ans.begin(),ans.end()); for(int i=0;i<(int)ans.size();i++) printf("%d ",ans[i]); return true; } return false; } signed main() { scanf("%d%d",&n,&k); for(int i=1;i<=n+k;i++) scanf("%d",&a[i]); sort(a+1,a+n+k+1); if(n<=k) { for(int i=1;i<=n+k;i++) for(int j=i+1;j<=n+k;j++) if(solve(a[i]+a[j])) exit(0); } else { mt19937 rng(time(0)); while(true) { int x=rng()%(n+k)+1; for(int i=max(1,(n+k-x)-3*(k+1));i<=min(n+k,(n+k-x)+3*(k+1));i++) if(x!=i&&solve(a[x]+a[i])) exit(0); } } }

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

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%d%d",&n,&k);
      |     ~~~~~^~~~~~~~~~~~~~
tabletennis.cpp:32:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     for(int i=1;i<=n+k;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...