Submission #771566

#TimeUsernameProblemLanguageResultExecution timeMemory
771566_martynasThe Big Prize (IOI17_prize)C++11
20 / 100
93 ms336 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; int find_best(int n) { mt19937 rng(0); int mx_sum = 0; for(int k = 0; k < 100; k++) { auto v = ask(rng() % n); mx_sum = max(mx_sum, v[0]+v[1]); } for(int i = 0; i < n; i++) { auto v = ask(i); int sum = v[0]+v[1]; if(sum == 0) { return i; } if(sum == mx_sum) { int l = i, r = n-1; while(l < r) { int m = (l+r+1)/2; auto v_p = ask(m); int sum_p = v_p[0]+v_p[1]; if(sum_p < mx_sum || v_p[0] > v[0]) { r = m-1; } else { l = m; } } i = l; } } return 0; } /* 5 2 2 2 1 2 8 3 3 2 3 3 2 1 3 sample: 8 3 2 3 1 3 3 2 3 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...