답안 #1036258

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1036258 2024-07-27T07:15:16 Z Alihan_8 커다란 상품 (IOI17_prize) C++17
20 / 100
39 ms 5524 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;
}


mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());
#define rnd(l, r) uniform_int_distribution <int> (l, r)(rng)

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];
	};
	
	int ans = -1;
	
	auto dnc = [&](auto dnc, int l, int r) -> void{
		if ( l > r ) return;
		
		int m = (l + r) / 2;
		
		auto c = f(m);
		
		if ( c[0] + c[1] == 0 ){
			ans = m;
		}
		
		int p = m, q = r + 1;
		
		while ( p + 1 < q ){
			int md = (p + q) / 2;
			
			if ( f(md) != c ){
				q = md;
			} else p = md;
		}
		
		dnc(dnc, l, m - 1), dnc(dnc, p + 1, r);
	};
	
	dnc(dnc, 0, n - 1);
	
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4952 KB Output is correct
2 Correct 4 ms 5044 KB Output is correct
3 Correct 3 ms 5156 KB Output is correct
4 Correct 2 ms 5292 KB Output is correct
5 Correct 4 ms 4952 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4952 KB Output is correct
8 Correct 4 ms 4952 KB Output is correct
9 Correct 4 ms 5044 KB Output is correct
10 Correct 3 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4952 KB Output is correct
2 Correct 3 ms 4952 KB Output is correct
3 Correct 3 ms 4952 KB Output is correct
4 Correct 3 ms 4952 KB Output is correct
5 Correct 3 ms 4952 KB Output is correct
6 Correct 5 ms 4952 KB Output is correct
7 Correct 3 ms 4952 KB Output is correct
8 Correct 4 ms 5044 KB Output is correct
9 Correct 3 ms 4952 KB Output is correct
10 Correct 3 ms 4952 KB Output is correct
11 Correct 11 ms 5196 KB Output is correct
12 Correct 13 ms 5208 KB Output is correct
13 Correct 9 ms 5204 KB Output is correct
14 Correct 10 ms 1104 KB Output is correct
15 Incorrect 39 ms 5524 KB Incorrect
16 Halted 0 ms 0 KB -