Submission #424081

#TimeUsernameProblemLanguageResultExecution timeMemory
424081lycTable Tennis (info1cup20_tabletennis)C++14
100 / 100
81 ms4400 KiB
#include <bits/stdc++.h> using namespace std; #define TRACE(x) cerr << #x << " :: " << x << endl #define _ << " " << #define SZ(x) ((int)(x).size()) #define ALL(x) (x).begin(),(x).end() #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define RFOR(i,a,b) for(int i=(a);i>=(b);--i) const int mxN = 150001 + 401; int N, K; int A[mxN], ls[mxN], rs[mxN], lp, rp; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> K; FOR(i,1,N+K){ cin >> A[i]; } FOR(i,1,K+1){ RFOR(j,N+K,N+i-1){ int mx = min(j-i+1-N, K-(i-1)-(N+K-j)); //TRACE(i _ j _ mx); int l = i, r = j; int a = i+1, b = j-1, c = 0; lp = 0; rp = 0; ls[lp++] = l; rs[rp++] = r; while (c <= mx && lp+rp < N && a < b) { int cur = A[a]+A[b], tgt = A[l]+A[r]; //TRACE(a _ b _ cur _ tgt); if (cur == tgt) { l = a, r = b; ls[lp++] = a++; rs[rp++] = b--; } else { ++c; if (cur < tgt) ++a; else --b; } } //TRACE(SZ(ls) _ SZ(rs) _ c); if (lp+rp == N) { FOR(x,0,lp-1) cout << A[ls[x]] << ' '; RFOR(x,rp-1,0) cout << A[rs[x]] << ' '; return 0; } } } assert(false); }
#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...