제출 #558079

#제출 시각아이디문제언어결과실행 시간메모리
558079aryan12커다란 상품 (IOI17_prize)C++17
20 / 100
69 ms336 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 450; vector<array<int, 3> > results; int N; bool cmp(array<int, 3> a, array<int, 3> b) { return ((a[0] + a[1]) > (b[0] + b[1])); } int DivideAndConquer(int l, int r) { // cout << "l = " << l << ", r = " << r << "\n"; if(l > r) { return -1; } int mid = (l + r) >> 1; vector<int> reply = ask(mid); if(reply[0] + reply[1] == 0) { // cout << "mid = " << mid << "\n"; return mid; } int value1 = -1, value2 = -1; if(reply[0] != 0) { value1 = DivideAndConquer(l, mid - 1); } if(reply[1] != 0) { value2 = DivideAndConquer(mid + 1, r); } if(value1 == -1 && value2 == -1) { return -1; } if(value1 == -1) { return value2; } return value1; } int find_best(int n) { return DivideAndConquer(0, n - 1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...