Submission #675133

#TimeUsernameProblemLanguageResultExecution timeMemory
675133Tuanlinh123Table Tennis (info1cup20_tabletennis)C++17
0 / 100
16 ms2844 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define pll pair<ll,ll> #define mp make_pair #define pb push_back #define fi first #define se second using namespace std; #define LOCALIO "C:/Users/admin/Documents/Code/" ll n, k, a[200005]; map <ll, ll> Map; void Try(ll sum) { if (Map[sum]==1) return; Map[sum]=1; ll l=1, r=n+k, num=0;; while (num<n/2) { while (a[l]+a[r]>sum) r--; if (a[l]+a[r]==sum) num++; l++; } if (num==n/2) { vector <ll> ans; l=1, r=n+k; ll cnt=0; while (ans.size()<n && cnt<=k) { while (a[l]+a[r]>sum) r--, cnt++; if (a[l]+a[r]==sum) ans.pb(a[l]), ans.pb(a[r]); else cnt++; l++; } sort(ans.begin(), ans.end()); for (ll i:ans) cout << i << " "; exit(0); } } int main() { #ifdef LOCAL freopen( LOCALIO "input.txt","r",stdin) ; freopen( LOCALIO "output.txt","w",stdout) ; #endif ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr); // freopen("FIBONACCI.inp","r",stdin); // freopen("FIBONACCI.out","w",stdout); cin >> n >> k; for (ll i=1; i<=n+k; i++) cin >> a[i]; for (ll i=1; i<=k+1; i++) for (ll j=n; j<=n+k; j++) Try(a[i]+a[j]); }

Compilation message (stderr)

tabletennis.cpp: In function 'void Try(long long int)':
tabletennis.cpp:36:26: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   36 |         while (ans.size()<n && cnt<=k)
      |                ~~~~~~~~~~^~
#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...