제출 #771929

#제출 시각아이디문제언어결과실행 시간메모리
771929_martynas커다란 상품 (IOI17_prize)C++11
0 / 100
82 ms292 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; const int jump = 256; int find_best(int n) { mt19937 rng(69420); uniform_int_distribution<int> dist(0, n-1); int mx_sum = 0; for(int k = 0; k < 100; k++) { int i = dist(rng); auto v = ask(i); if(v[0] + v[1] == 0) return 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) { vector<int> v_p; // if(i+jump < n) { // v_p = ask(i+jump); // if() { // // } // } int l = i, r = n-1; while(l < r) { int m = (l+r+1)/2; 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...