답안 #1043003

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1043003 2024-08-03T17:34:29 Z Mr_Husanboy 커다란 상품 (IOI17_prize) C++17
20 / 100
24 ms 428 KB
#include "prize.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ff first
#define ss second
#define all(a) (a).begin(), (a).end()

template<typename T>
int len(T &a){
	return a.size();
}

int find_best(int n) {
	// if(n <= 5000){
	// 	for(int i = 0; i < n; i ++){
	// 		if(ask(i) == vector<int>{0, 0}){
	// 			return i;
	// 		}
	// 	}
	// }
	int j = 0;
	int rig = 0;
	while(true){
		auto v = ask(j);
		if(v[0] + v[1] == 0){
			return j;
		}
		if(n - v[0] + v[1] > n / 2){
			rig = v[1];
			break;
		}
		j ++;
	}
	// for(int i = 0; i < 100; i++){
	// 	cout << "2 ";
	// }cout << "1" << endl;
	// cout << j << endl;
	while(true){
		int l = j, r = n;
		while(r - l > 1){
			int m = (l + r) / 2;
			vector<int> v = ask(m);
			if(v[0] + v[1] == 0){
				return m;
			}
			if(v[1] == rig){
				l = m;
			}else r = m;
		}
		j = r + 1;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 424 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 428 KB Output is correct
7 Correct 0 ms 344 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 1 ms 344 KB Output is correct
2 Correct 1 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 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 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 Incorrect 24 ms 344 KB Incorrect
12 Halted 0 ms 0 KB -