제출 #72819

#제출 시각아이디문제언어결과실행 시간메모리
72819funcsr커다란 상품 (IOI17_prize)C++17
20 / 100
78 ms572 KiB
#include "prize.h" #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <cmath> #include <cassert> #include <random> using namespace std; #define rep(i,n)for (int i=0; i<(n); i++) #define all(x) (x).begin(), (x).end() #define pb push_back #define _1 first #define _2 second #define INF 1145141919 #define ret(x) {int cache=(x);if(cache!=-1)return cache;} typedef pair<int, int> P; mt19937 mt_rand(114514); int mp = 0; int solve(int l, int r, int num, int left) { if (num == 0) return -1; int mid = (l+r)/2; for (; mid>=l; mid--) { vector<int> ret = ask(mid); if (ret[0]+ret[1] == 0) return mid; if (ret[0]+ret[1] != mp) continue; if (mid > l) { ret(solve(l, mid-1, ret[0]-left, left)); } if (mid < r) { ret(solve(mid+1, r, num-ret[0], left+ret[0])); } } return -1; } int find_best(int N) { rep(i, 30) { vector<int> ret = ask(mt_rand()%N); mp = max(mp, ret[0]+ret[1]); } assert(mp < 500); return solve(0, N-1, mp, 0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...