답안 #46874

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
46874 2018-04-24T10:30:58 Z Kerim 커다란 상품 (IOI17_prize) C++17
컴파일 오류
0 ms 0 KB
#include "bits/stdc++.h"
//~ #include "prize.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
//~ vector<int>arr;
//~ int cnt=0;
//~ vector<int>ask(int x){
	//~ int a=0,b=0;
	//~ for(int i=0;i<x;i++)
		//~ a+=(arr[x]>arr[i]);
	//~ for(int i=x+1;i<(int)arr.size();i++)
		//~ b+=(arr[x]>arr[i]);
	//~ vector<int>v;v.pb(a);v.pb(b);	
	//~ cnt++;
	//~ return v;
//~ }
const int C=1000;
int find_best(int n){
	int mx=0;
	for(int i=0;i<n;i++){
		vector<int>res=ask(i);
		if(res[0]+res[1]==0)
			return i;
		umax(mx,res[0]+res[1]);
		if(res[0]+res[1]<mx)
			continue;
		if(i+C<n and ask(i+C)==res){
			i+=C;
			continue;
		}
		int st=i+1,en=min(n-1,i+C);
		while(st<=en){
			int mid=(st+en)>>1;
			if(ask(mid)==res){
				i=mid;
				st=mid+1;
			}
			else
				en=mid-1;
		}	
	}
	return -1;
}
//~ int main(){
    //~ freopen("file.in", "r", stdin);
    //~ int n;
    //~ scanf("%d",&n);
    //~ for(int i=0;i<n;i++){
		//~ int x;
		//~ scanf("%d",&x);
		//~ arr.pb(x);
	//~ }
	//~ for(int i=0;i<n;i++)
		//~ if(arr[i]==1){
			//~ if(find_best(n)==i)
				//~ puts("ok");
			//~ else
				//~ puts("wa");
			//~ debug(cnt);	
			//~ return 0;
		//~ }
	//~ return 0;
//~ }

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:37:18: error: 'ask' was not declared in this scope
   vector<int>res=ask(i);
                  ^~~