제출 #284276

#제출 시각아이디문제언어결과실행 시간메모리
284276Fasho커다란 상품 (IOI17_prize)C++14
20 / 100
79 ms384 KiB
#include <bits/stdc++.h>
#include "prize.h"
#define N 100005
#define ll long long int
#define fo(i,x,y)	for(int i=x;i<=y;i++)
#define fs(ar,n) fo(i,1,n) cin>>ar[i]
#define sp " "
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll> 
#define fast2 freopen ("in.txt","r",stdin);freopen ("out.txt","w",stdout);
#define mod 1000000007
using namespace std;

ll nn,m,ar[N],sum,t,a,b;

void bs(ll l,ll r)
{
	if(a==b)
		return;
	
	l=max(l,a);
	r=min(r,b);
	if(l>r)
		return;
	if(l==r)
	{
		a=l,r=l;
		return;
	}
	// cout<<l<<sp<<r<<endl;
	ll mid=(l+r)/2;
	std::vector<int> res = ask(mid);
	if(!res[0] && !res[1])
	{
		a=mid,b=mid;
		return;
	}
	if(!res[0])
		a=max(a,mid+1),l=mid+1;
	if(!res[1])
		b=min(b,mid-1),r=mid-1;
	if(res[0])
		bs(l,mid-1);
	if(res[1])
		bs(mid+1,r);

}

int find_best(int n) 
{
	a=0;
	b=n-1;
	bs(0,n-1);
	return a;
}

// ll n,m,ar[N],sum,t;

// int main()
// {
// 	fast;
// 	cin>>n;
// } 
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...