Submission #1045028

#TimeUsernameProblemLanguageResultExecution timeMemory
1045028MalixTable Tennis (info1cup20_tabletennis)C++14
100 / 100
202 ms3188 KiB
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; #define REP(i,a,b) for(int i=a;i<b;i++) #define PB push_back int n,k; vi a,ans; bool solve(int x){ int l=0,r=n+k-1;ans.clear(); while(l<r&&ans.size()<n){ while(l<r&&a[l]+a[r]>x)r--; if(l<r&&a[l]+a[r]==x){ ans.PB(a[l]);ans.PB(a[r]); } if(r-l+1+ans.size()<n)break; l++; } sort(ans.begin(),ans.end()); return ans.size()==n; } int main() { cin>>n>>k;a.resize(n+k); REP(i,0,n+k)cin>>a[i]; REP(i,0,k+1)REP(j,n-1,n+k)if(solve(a[i]+a[j])){ for(auto u:ans)cout<<u<<" "; return 0; } }

Compilation message (stderr)

tabletennis.cpp: In function 'bool solve(int)':
tabletennis.cpp:10:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 |     while(l<r&&ans.size()<n){
      |                ~~~~~~~~~~^~
tabletennis.cpp:15:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |         if(r-l+1+ans.size()<n)break;
      |            ~~~~~~~~~~~~~~~~^~
tabletennis.cpp:19:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |     return ans.size()==n;
      |            ~~~~~~~~~~^~~
#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...