Submission #675094

#TimeUsernameProblemLanguageResultExecution timeMemory
675094Tuanlinh123Table Tennis (info1cup20_tabletennis)C++17
9 / 100
3080 ms127912 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 a[200005]; map <ll, ll> Map; 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); ll n, k; cin >> n >> k; for (ll i=1; i<=n+k; i++) cin >> a[i]; for (ll i=1; i<=(n+k)/2; i++) for (ll j=max(i+1, n-i+1-k); j<=min(n-i+1+k, n); j++) Map[a[i]+a[j]]++; ll sum=0; for (pll i:Map) if (i.se>=n/2) sum=i.fi; vector <ll> ans; ll l=1, r=n+k; while (ans.size()<n) { while (a[l]+a[r]>sum) r--; if (a[l]+a[r]==sum) ans.pb(a[l]), ans.pb(a[r]); l++; } sort(ans.begin(), ans.end()); for (ll i:ans) cout << i << " "; }

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:39:22: 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]
   39 |     while (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...