답안 #1036321

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1036321 2024-07-27T08:44:37 Z Alihan_8 커다란 상품 (IOI17_prize) C++17
0 / 100
57 ms 5768 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 = 0;

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][0] + dp[j][1];
	};
	
	for ( int i = 0; i < n; i++ ){
		int opt = -1, k = -1;
		
		if ( f(i) == 0 ) return i;
		
		for ( int j = i; j < min(n, i + B); j++ ){
			int x = f(j);
			
			if ( x == 0 ){
				return j;
			}
			
			if ( chmax(opt, x) || opt == x ){
				k = j;
			} 
		}
		
		int l = i, r = n;
		
		while ( l + 1 < r ){
			int m = (l + r) / 2;
			
			if ( f(m) != opt ){
				r = m;
			} else l = m;
		}
		
		i = max(i + B - 1, l);
	}
	
	assert(false);
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:47:17: warning: variable 'k' set but not used [-Wunused-but-set-variable]
   47 |   int opt = -1, k = -1;
      |                 ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 57 ms 5384 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 5768 KB Incorrect
2 Halted 0 ms 0 KB -