제출 #328288

#제출 시각아이디문제언어결과실행 시간메모리
328288arnold518커다란 상품 (IOI17_prize)C++14
20 / 100
86 ms2028 KiB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2e5;

int N;
pii M[MAXN+10];

pii query(int x)
{
	if(M[x]!=pii(-1, -1)) return M[x];
	vector<int> res=ask(x-1);
	return M[x]=pii(res[0], res[1]);
}

int find_best(int _N)
{
	N=_N;
	for(int i=1; i<=N; i++) M[i]=pii(-1, -1);

	for(int i=1; i<=N;)
	{
		pii p=query(i);
		if(p.first==0 && p.second==0) return i-1;
		int lo=i, hi=N+1;
		while(lo+1<hi)
		{
			int mid=lo+hi>>1;
			if(query(mid)==p) lo=mid;
			else hi=mid;
		}
		i=hi;
	}
}

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:33:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   33 |    int mid=lo+hi>>1;
      |            ~~^~~
prize.cpp:39:1: warning: control reaches end of non-void function [-Wreturn-type]
   39 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...