제출 #374627

#제출 시각아이디문제언어결과실행 시간메모리
374627Alex_tz307Table Tennis (info1cup20_tabletennis)C++17
100 / 100
78 ms4588 KiB
#include <bits/stdc++.h> using namespace std; const int NMAX = 1e5 + 5e4 + 5 + 4; const int KMAX = 404; int N, K, M, a[NMAX + KMAX], sol[NMAX]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> N >> K; M = N + K; for(int i = 1; i <= M; ++i) cin >> a[i]; for(int i = 1; i <= K + 1; ++i) for(int j = i + N - 1; j <= M; ++j) { /// consideram i primul element al sirului solutie si j ultimul int sum = a[i] + a[j], st = i, dr = j, cnt = 0; while(st < dr) { if((dr - st + 1) < (N - (cnt << 1))) break; int cand = a[st] + a[dr]; if(cand == sum) { sol[++cnt] = a[st]; sol[N - cnt + 1] = a[dr]; ++st, --dr; } else if(cand > sum) --dr; else ++st; if(cnt == N / 2) break; } if(cnt == N / 2) { for(int k = 1; k <= N; ++k) cout << sol[k] << ' '; cout << '\n'; 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...