제출 #542985

#제출 시각아이디문제언어결과실행 시간메모리
542985MilosMilutinovic커다란 상품 (IOI17_prize)C++14
96.82 / 100
52 ms10000 KiB
#include "prize.h"
#include <bits/stdc++.h>
#define SZ 200005

using namespace std;
typedef pair <int,int> P;

map <int,int> ve[SZ];
int ret=-1;

P query(int id)
{
	auto v=ask(id);
	return {v[0],v[1]};
}
void solve(int l,int r)
{
	if(ret!=-1||l>r) return;
	int mid=l+r>>1;
	P v=query(mid);
	int sz=v.first+v.second;
	if(sz==0)
	{
		ret=mid;
		return;
	}
	bool L=true,R=true;
	auto it=ve[sz].upper_bound(mid);
	if(it!=ve[sz].begin()&&(*prev(it)).second==v.first) L=false;
	if(it!=ve[sz].end()&&(*it).second==v.first) R=false;
	ve[sz][mid]=v.first;
	if(L) solve(l,mid);
	if(R) solve(mid+1,r);
}
int find_best(int n)
{
	solve(0,n-1);
	return ret;
}

컴파일 시 표준 에러 (stderr) 메시지

prize.cpp: In function 'void solve(int, int)':
prize.cpp:19:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   19 |  int mid=l+r>>1;
      |          ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...