Submission #64598

# Submission time Handle Problem Language Result Execution time Memory
64598 2018-08-05T03:03:08 Z nvmdava The Big Prize (IOI17_prize) C++17
Compilation error
0 ms 0 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
 
 
vector<int> ans[210000];
int mx = -1;

int find_best(int n) {
	
	for(int i = 0; i < 500; i++){
		ans[i] = ask(i);
		if(ans[i][0] + ans[i][1] == 0){
			return i;
		}
		mx = max(mx, ans[i][0] + ans[i][1]);
	}
	int id = 0;
	while(id < n){	
		while(ans[id][0] + ans[id][1] != mx){
			id++;
			ans[id]  = ask(id);
			if(ans[id][0] + ans[id][1] == 0) return i;
		}
		int l = id, r = n - 1;
		int k = 0;
		while(l <= r)
		{
			int m = (l + r) >> 1;
			ans[m] = ask(m);
			if(ans[m][1] != ans[id][1] || ans[m][0] + ans[m][1] < mx) r = m - 1;
			else {
				l = m + 1;
				k = m;
			}
		}
		id = k + 1;
	}
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:23:44: error: 'i' was not declared in this scope
    if(ans[id][0] + ans[id][1] == 0) return i;
                                            ^
prize.cpp:23:44: note: suggested alternative: 'id'
    if(ans[id][0] + ans[id][1] == 0) return i;
                                            ^
                                            id