답안 #977374

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
977374 2024-05-07T20:05:47 Z mariaclara 커다란 상품 (IOI17_prize) C++17
20 / 100
42 ms 596 KB
#include "prize.h"
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mk make_pair
#define pb push_back
#define fr first
#define sc second

int find_best(int n) {
	int i = 0, at = 0;

	map<int,pii> resp;
	while(1) {
		// achar primeiro cara mais valioso doq um pirulito de indice maior que i
		int l = i, r = n-1;
		while(l <= r) {
			int mid = (l+r)/2;
			vector<int> aux;
			if(resp.count(mid) == 0) aux = ask(mid);
			else aux = {resp[mid].fr};
			if(aux[0] > at) r = mid-1;
			else l = mid+1;
		}
		at++;
		i = r;
		vector<int> aux;
		if(resp.count(i) == 0) aux = ask(i);
		else aux = {resp[i].fr, resp[i].sc};
		if(aux[0] + aux[1] == 0) return i;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 596 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Incorrect 42 ms 344 KB Incorrect
16 Halted 0 ms 0 KB -