Submission #845921

#TimeUsernameProblemLanguageResultExecution timeMemory
845921PiokemonTable Tennis (info1cup20_tabletennis)C++17
100 / 100
138 ms13316 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; constexpr int N = 15e4; ll a[N+9+500]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,k; cin >> n >> k; for (int x=1;x<=n+k;x++) cin >> a[x]; map<ll,bool>spr; ll znal=-1; for (int x=1;x<=k+1;x++){ for (int y=max(x+1,n);y<=n+k;y++){ if (spr[a[x]+a[y]])continue; ll cel=a[x]+a[y]; spr[cel]=1; int l,r,pomin; l = 1; r = n+k; pomin = 0; while(l<r){ if (pomin>k) break; if (a[l]+a[r]<cel){l++;pomin++;} else if (a[l]+a[r]==cel){l++;r--;} else {r--;pomin++;} } if (l==r)pomin++; if (pomin<=k){ znal=cel; break; } } if (znal!=-1) break; } vector<int> odp; int l,r; l = 1; r = n+k; while(l<r){ if (odp.size()==n)break; if (a[l]+a[r]<znal) l++; else if (a[l]+a[r]==znal){ odp.push_back(a[l]); odp.push_back(a[r]); l++; r--; } else r--; } sort(odp.begin(),odp.end()); for (int x:odp) cout << x << ' '; }

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:45:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |   if (odp.size()==n)break;
      |       ~~~~~~~~~~^~~
#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...