Submission #691386

#TimeUsernameProblemLanguageResultExecution timeMemory
691386AiperiiiTable Tennis (info1cup20_tabletennis)C++14
100 / 100
71 ms5724 KiB
#include <bits/stdc++.h> using namespace std; int n,k; long long a[150401]; void check(int begin,int end){ vector <long long> ans; int l=begin+1; int r=end-1; int bad=begin+n+k+1-end; long long t=a[r]+a[l]; while(l<r){ long long c=a[r]+a[l]; if(c==t){ ans.push_back(a[r]); ans.push_back(a[l]); l++; r--; if(ans.size()==n){ sort(ans.begin(),ans.end()); for(int i=0;i<ans.size();i++){ cout<<ans[i]<<" "; } exit(0); } } else if(c<t){ l++; bad++; } else{ r--; bad++; } if(bad>k){ return; } } } int main(){ cin.tie(0); ios_base::sync_with_stdio(0); cin>>n>>k; for(int i=1;i<=n+k;i++){ cin>>a[i]; } for(int i=0;i<=k;i++){ for(int j=0;j<=k-i;j++){ check(i,n+k+1-j); } } }

Compilation message (stderr)

tabletennis.cpp: In function 'void check(int, int)':
tabletennis.cpp:18:26: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |             if(ans.size()==n){
      |                ~~~~~~~~~~^~~
tabletennis.cpp:20:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |                 for(int i=0;i<ans.size();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...