제출 #216191

#제출 시각아이디문제언어결과실행 시간메모리
216191PajarajaTable Tennis (info1cup20_tabletennis)C++17
100 / 100
626 ms5508 KiB
#include <bits/stdc++.h> #define MAXN 200007 #define MAXK 407 using namespace std; int a[MAXN],n,k,m; mt19937 rng(time(NULL)); bool check(int s) { int t1=1,t2=m; vector<pair<int,int> > p; while(t1<t2) { if(a[t1]+a[t2]==s) p.push_back({t1,t2}); if(a[t1]+a[t2]<=s) t1++; if(a[t1]+a[t2]>s) t2--; } if(p.size()<n/2) return false; for(int i=0;i<n/2;i++) printf("%d ",a[p[i].first]); for(int i=n/2-1;i>=0;i--) printf("%d ",a[p[i].second]); return true; } int main() { scanf("%d%d",&n,&k); m=n+k; for(int i=1;i<=m;i++) scanf("%d",&a[i]); if(n>k) { bool found=false; while(!found) { int x=rng()%m+1; for(int i=max(m+1-x-k,1);i<=min(m+1-x+k,m) && !found;i++) found=check(a[i]+a[x]); } } else { bool found=false; for(int i=1;i<=k+1 && !found;i++) for(int j=m;j>=m-k-1 && !found;j--) found=check(a[i]+a[j]); } }

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

tabletennis.cpp: In function 'bool check(int)':
tabletennis.cpp:17:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(p.size()<n/2) return false;
     ~~~~~~~~^~~~
tabletennis.cpp: In function 'int main()':
tabletennis.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&k); m=n+k;
  ~~~~~^~~~~~~~~~~~~~
tabletennis.cpp:25:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=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...