답안 #1035401

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1035401 2024-07-26T10:16:24 Z ALeonidou 커다란 상품 (IOI17_prize) C++17
20 / 100
1 ms 428 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;

#define ll int
#define endl "\n"
#define sz(x) (ll)x.size()
#define F first
#define S second
#define pb push_back

typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <ii> vii;

#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;

void printVct(vi &v){
	for (ll i =0; i<sz(v); i++){
		cout<<v[i]<<" ";
	}
	cout<<endl;
}

int find_best(int n) {	
	// for(int i = 0; i < n; i++) {
	// 	std::vector<int> res = ask(i);
	// 	if(res[0] + res[1] == 0)
	// 		return i;
	// }

	ll l = 0, r = n-1, mid;
	while (l <= r){
		mid = (l+r) / 2;
		vi v = ask(mid);
		if (v[0] == 0 && v[1] == 0){
			return mid;
		}
		else if (v[0] == 1){	//go left
			r = mid-1;
		}
		else{
			l = mid+1;
		}
	}

	return -1;
}

/*
6
1 2 2 2 2 2
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 424 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 1 ms 344 KB Output is correct
7 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 428 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 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 0 ms 344 KB Integer -1 violates the range [0, 199999]
12 Halted 0 ms 0 KB -