제출 #249845

#제출 시각아이디문제언어결과실행 시간메모리
249845srvlt커다란 상품 (IOI17_prize)C++14
20 / 100
84 ms5072 KiB
#include "prize.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vector <int> v, a[200003];
int n, mx = -1, val = -1, cur = -1, have = 0;

int find_next() {
	int l = cur, r = n;
	while (l < r - 1) {
		int mid = l + r >> 1;
		v = ask(mid);
		if (v[0] + v[1] == val && v[0] == have) l = mid;
		else r = mid;
		a[mid] = v;
	}
	assert(r != n);
	return r;
}

int find_best(int _n) {
	n = _n;
	for (int i = 0; i < min(n, 500); i++) {
		v = ask(i);
		if (mx == -1 || val < v[0] + v[1]) {
			mx = i, val = v[0] + v[1];
		}
	}
	int cur = -1;
	while (true) {
		cur = find_next();
		have++;
		if (a[cur][0] == 0 && a[cur][1] == 0) return cur;
	}
}

컴파일 시 표준 에러 (stderr) 메시지

prize.cpp: In function 'int find_next()':
prize.cpp:21:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = l + r >> 1;
             ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...