답안 #1045190

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1045190 2024-08-05T18:29:56 Z beaconmc 커다란 상품 (IOI17_prize) C++14
0 / 100
149 ms 2264 KB
#include "prize.h"

#include <bits/stdc++.h>
 
typedef int ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
 
using namespace std;


map<ll, vector<ll>> cache;

vector<ll> query(int n){
	if (cache.count(n)) return cache[n];
	else return cache[n] = ask(n);
}


int find_best(int n) {
	cache.clear();
	vector<ll> stuff(n);

	FOR(i,0,n) stuff[i] = i;
	

	vector<ll> found;

	ll ans = -1;


	while (ans == -1){


		ll lo = 0;
		ll hi = stuff.size();
		while (lo < hi){

			ll mid = (lo+hi)/2;

			vector<ll> sus = query(stuff[mid]);

			if (sus[0] + sus[1] < n/2){

				if (sus[0]+sus[1]==0) return stuff[mid];
				found.push_back(stuff[mid]);
				stuff.erase(stuff.begin()+mid);
				break;
			}else{
				sort(found.begin(), found.end());
				ll idk = upper_bound(found.begin(), found.end(), stuff[mid]) - found.begin();
				if (idk < sus[0]){
					hi = mid;
				}else{
					lo = mid+1;
				}
			}
		}
	}
	return 0;

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 128 ms 2100 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 149 ms 2264 KB Incorrect
2 Halted 0 ms 0 KB -