제출 #423789

#제출 시각아이디문제언어결과실행 시간메모리
423789lycTable Tennis (info1cup20_tabletennis)C++14
49 / 100
3090 ms1636 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; const int mxK = 401; int N, K; int A[mxN]; 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; vector<int> ls = {l}, rs = {r}; while (SZ(ls)+SZ(rs) < N && a < b && c <= mx) { int cur = A[a]+A[b], tgt = A[l]+A[r]; //TRACE(a _ b _ cur _ tgt); if (cur == tgt) { l = a, r = b; ls.push_back(a++); rs.push_back(b--); } else { if (cur < tgt) ++a, ++c; else --b, ++c; } } //TRACE(SZ(ls) _ SZ(rs) _ c); if (SZ(ls)+SZ(rs) == N) { for (int& x : ls) cout << A[x] << ' '; reverse(ALL(rs)); for (int& x : rs) cout << A[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...