Submission #1036555

# Submission time Handle Problem Language Result Execution time Memory
1036555 2024-07-27T13:49:49 Z Alihan_8 The Big Prize (IOI17_prize) C++17
20 / 100
47 ms 5648 KB
#include "prize.h"

#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define ar array
#define pb push_back
#define ln '\n'
//#define int long long

using i64 = long long;

template <class F, class _S>
bool chmin(F &u, const _S &v){
    bool flag = false;
    if ( u > v ){
        u = v; flag |= true;
    }
    return flag;
}

template <class F, class _S>
bool chmax(F &u, const _S &v){
    bool flag = false;
    if ( u < v ){
        u = v; flag |= true;
    }
    return flag;
}

const int B = 500;

int find_best(int n){
	vector <vector<int>> dp(n);	
	
	auto f = [&](int j){
		if ( dp[j].empty() ){
			dp[j] = ask(j);
		}
		
		return dp[j];
	};
	
	auto g = [&](int j){
		return f(j)[0] + f(j)[1];
	};
	
	int mx = -1, k = -1;
	
	for ( int i = 0; i < min(n, B); i++ ){
		if ( chmax(mx, g(i)) ){
			k = i;
		}
		
		if ( g(i) == 0 ){
			return i;
		}
	}
	
	for ( int i = k; i < n;){
		int l = i, r = min(n, l + B);
		
		while ( l + 1 < r ){
			int m = (l + r) / 2;
			
			if ( f(m)[1] != f(i)[1] ){
				r = m;
			} else l = m;
		}
		
		int j = r;
		
		while ( j < n && f(j) != f(i) ){
			if ( g(j) == 0 ){
				return j;
			} j++;
		}
		
		i = j;
	}
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4952 KB Output is correct
2 Correct 13 ms 5176 KB Output is correct
3 Correct 14 ms 5176 KB Output is correct
4 Correct 26 ms 5200 KB Output is correct
5 Correct 10 ms 5208 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 9 ms 5200 KB Output is correct
8 Correct 11 ms 5192 KB Output is correct
9 Correct 11 ms 5160 KB Output is correct
10 Correct 15 ms 5176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5208 KB Output is correct
2 Correct 12 ms 5228 KB Output is correct
3 Correct 12 ms 5208 KB Output is correct
4 Correct 26 ms 5208 KB Output is correct
5 Correct 11 ms 5188 KB Output is correct
6 Correct 2 ms 4952 KB Output is correct
7 Correct 12 ms 5176 KB Output is correct
8 Correct 9 ms 4952 KB Output is correct
9 Correct 12 ms 5228 KB Output is correct
10 Correct 23 ms 5240 KB Output is correct
11 Incorrect 47 ms 5648 KB Incorrect
12 Halted 0 ms 0 KB -