답안 #937272

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
937272 2024-03-03T18:04:52 Z snpmrnhlol 커다란 상품 (IOI17_prize) C++17
0 / 100
2 ms 344 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
const int K = 500;
const int L = 5000;
const int mod = 1e9 + 7;
set <int> s;
int cnt = 0;
int mx = 0;
int qcount = 0;
int ans = -1;
int seed = 37;
int f(){
    seed = 1ll*seed*seed%mod;
    return seed;
}
void solve(int l,int r,int dl,int dr){
    if(dl + dr >= mx)return;
    if(l > r)return;
    int mij = (l + r)/2;
    for(int i = mij;i <= r;i++){
        auto x = ask(i);
        if(x[0] + x[1] == mx){
            x[0]-=dl;
            x[1]-=dr;
            int nr = f();
            if(nr%2 == 0){
                solve(i + 1,r,x[0] + dl,dr);
                if(ans != -1)return;
                solve(l,mij - 1,dl,dr + x[1] + i - mij);
            }else{
                solve(l,mij - 1,dl,dr + x[1] + i - mij);
                if(ans != -1)return;
                solve(i + 1,r,x[0] + dl,dr);
            }
            return;
        }else{
            if(x[0] + x[1] == 0){
                ans = i;
                return;
            }
        }
    }
    solve(l,mij - 1,dl,dr);
    return;
}
int find_best(int n) {
    for(int i = 0;i < min(n,K);i++){
        auto x = ask(i);
        //qcount++;
        //if(qcount >= L)break;
        int nr = x[0] + x[1];
        if(nr == 0)return i;
        if(nr > mx){
            mx = nr;
            cnt = 1;
        }else if(nr == mx){
            cnt++;
        }
    }
    solve(min(n,K),n - 1,cnt,0);
	return ans;
}
/**
8
3 3 3 3 2 2 2 1
**/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 344 KB Integer -1 violates the range [0, 199999]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 344 KB Integer -1 violates the range [0, 199999]
2 Halted 0 ms 0 KB -