Submission #685674

#TimeUsernameProblemLanguageResultExecution timeMemory
685674heeheeheehaawTable Tennis (info1cup20_tabletennis)C++17
0 / 100
65 ms2380 KiB
#include <iostream> #include <vector> #include <algorithm> #include <map> using namespace std; //ifstream cin("test.in"); //ofstream cout("test.out"); int n, k; int v[200005]; pair<int, int> rez[200005]; bool possible(int sum) { int st = 1, dr = n + k, cnt = 0; while (st < dr && cnt < n / 2 && (dr - st + 1) / 2 + cnt >= n / 2) { if (v[st] + v[dr] == sum) rez[++cnt] = {st++, dr--}; else if (v[st] + v[dr] < sum) st++; else dr--; } return (cnt >= n / 2); } void solve() { bool ok = false; for(int i = 1; i <= k; i++) for(int j = n; j <= n + k && !ok; j++) if(i < j && possible(v[i] + v[j])) ok = true; for(int i = 1; i <= n / 2; i++) cout<<rez[i].first<<" "; for(int i = n / 2; i >= 1; i--) cout<<rez[i].second<<" "; return; } int main() { cin>>n>>k; for(int i = 1; i <= n + k; i++) cin>>v[i]; solve(); 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...