제출 #686607

#제출 시각아이디문제언어결과실행 시간메모리
686607alexdumitruTable Tennis (info1cup20_tabletennis)C++14
87 / 100
3084 ms2964 KiB
#include <iostream> using namespace std; const int nmax = 150000; const int kmax = 400; int a[nmax + kmax]; int n, k; pair < int, int > ans[nmax / 2]; int check ( int sum ) { int st = 0, dr = n + k - 1, cnt = 0; while ( st < dr && cnt < n / 2 && st < dr ) { if ( a[st] + a[dr] == sum ) ans[cnt++] = { st++, dr-- }; else if ( a[st] + a[dr] < sum ) st++; else dr--; } return cnt >= n / 2; } int main() { cin >> n >> k; for ( int i = 0; i < n + k; i++ ) cin >> a[i]; bool ok = false; for ( int i = 0; i <= k && !ok; i++ ) for ( int j = n - 1; j < n + k && !ok; j++ ) if ( i < j && check ( a[i] + a[j] ) ) ok = true; for ( int i = 0; i < n / 2; i++ ) cout << a[ans[i].first] << ' '; for ( int i = n / 2 - 1; i >= 0; i-- ) cout << a[ans[i].second] << ' '; return 0; }
#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...