답안 #790688

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
790688 2023-07-23T06:11:56 Z PoonYaPat 커다란 상품 (IOI17_prize) C++14
컴파일 오류
0 ms 0 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;

int mmax=0,st;
vector<int> val[200005];
vector<int> none;

void find_nxt() { //find the next non-lollipop
	int l=st+1,r=n-1;
	while (l<r) {
		int mid=(l+r)/2;
		val[mid]=ask(mid);
		if (val[mid][0]+val[mid][1]!=mmax) r=mid;
		else if (val[mid][0]!=val[st][0]) r=mid;
		else l=mid+1;
	}
	none.push_back(l);
	for (int i=l+1; i<n; ++i) {
		val[i]=ask(i);
		if (val[i][0]+val[i][1]!=mmax) none.push_back(i);
		else {
			st=i;
			find_nxt();
		}
	}
}

int find_best(int n) {
	for (int i=0; i<min(500,n); ++i) {
		val[i]=ask(i);
		mmax=max(mmax,val[i][0]+val[i][1]);
	}
	for (int i=0; i<min(500,n); ++i) {
		if (val[i][0]+val[i][1]==mmax) {
			st=i;
			find_nxt();
			break;
		} else none.push_back(i);
	}

	for (auto s : none) {
		val[s]=ask(s);
		if (val[s][0]+val[s][1]==0) return s;
	}
}

Compilation message

prize.cpp: In function 'void find_nxt()':
prize.cpp:10:15: error: 'n' was not declared in this scope
   10 |  int l=st+1,r=n-1;
      |               ^
prize.cpp: In function 'int find_best(int)':
prize.cpp:46:1: warning: control reaches end of non-void function [-Wreturn-type]
   46 | }
      | ^