답안 #538879

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
538879 2022-03-17T23:26:33 Z Deepesson 커다란 상품 (IOI17_prize) C++17
100 / 100
48 ms 344 KB
#include <bits/stdc++.h>
#include "prize.h"
typedef std::pair<int,int> pii;
int diamante=-1;
int N;
pii pergunta(int p){
    auto x = ask(p-1);
    if(!(x[0]+x[1])){
        diamante=p;
    }
    return {x[0],x[1]};
}
int range = 480;
int maxa=0;
void cdc(int l=1,int r=N,int left=0,int right=0){
    if(diamante!=-1)return;
    if(l>r)return;
    if(left+right==maxa)return;

    int curl=0,curr=1;
    int m = (l+r)/2;
    int computou=0;
    int size=r-l+1;
    pii ans;
    int lf=m,rf=m;
    int split=m;

    while(computou!=size){
        if(left+right+computou==maxa)return;
        if(curl<curr){
            int novpos = m-curl;
            ++curl;
            if(novpos<l){continue;}
            lf=novpos;
            split=novpos;
            ans = pergunta(novpos);
            if(ans.first+ans.second==maxa)break;
        }else {
            int novpos = m+curr;
            ++curr;
            if(novpos>r){continue;}
            rf=novpos;
            split=novpos;
            ans = pergunta(novpos);
            if(ans.first+ans.second==maxa)break;
        }
        ++computou;
    }

    if(computou+1>=size)return;

    if(split==lf){
        cdc(l,lf-1,left,ans.second);
    }
    else if(split==rf&&lf-1>=l){
       /// assert(cheatask(lf-2)[1]==ans.second+computou);
        cdc(l,lf-1,left,ans.second+computou);
    }else assert(0);///Erro! Eh na direita ou esquerda

    if(split==lf&&r>=rf+1){
      ///  std::cout<<cheatask(rf)[0]<<"!!\n";
       /// std::cout<<computou<<" "<<cheatask(rf)[0]<<" "<<ans.first<<" ("<<lf<<"  "<<rf<<") "<<l<<" "<<r<<" "<<g[split]<<"\n";
     ///   assert(ans.first+computou==cheatask(rf)[0]);
        cdc(rf+1,r,ans.first+computou,right);
    }
    else if(split==rf){
        cdc(rf+1,r,ans.first,right);
    }else assert(0);///Erro! Eh na direita ou esquerda

}

int find_best(int n) {
    N=n;
    range=std::min(range-1,N);
    std::vector<int> vals;
    for(int i=1;i<range;++i){
        pii u = pergunta(i);
        maxa=std::max(u.first+u.second,maxa);
        if(maxa>100){
            range=i+1;
            break;
        }
        vals.push_back(u.first+u.second);
    }
    int count=0;
    for(auto&x:vals)if(x<maxa)++count;
    cdc(range,N,count,0);
    assert(diamante!=-1);
    return diamante-1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 296 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 4 ms 272 KB Output is correct
4 Correct 3 ms 288 KB Output is correct
5 Correct 6 ms 284 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 5 ms 208 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 336 KB Output is correct
10 Correct 5 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 4 ms 292 KB Output is correct
3 Correct 3 ms 300 KB Output is correct
4 Correct 8 ms 208 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 2 ms 300 KB Output is correct
7 Correct 4 ms 292 KB Output is correct
8 Correct 3 ms 292 KB Output is correct
9 Correct 4 ms 208 KB Output is correct
10 Correct 5 ms 300 KB Output is correct
11 Correct 5 ms 276 KB Output is correct
12 Correct 4 ms 208 KB Output is correct
13 Correct 9 ms 296 KB Output is correct
14 Correct 2 ms 208 KB Output is correct
15 Correct 6 ms 208 KB Output is correct
16 Correct 37 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 17 ms 292 KB Output is correct
19 Correct 1 ms 292 KB Output is correct
20 Correct 6 ms 292 KB Output is correct
21 Correct 14 ms 208 KB Output is correct
22 Correct 3 ms 208 KB Output is correct
23 Correct 5 ms 292 KB Output is correct
24 Correct 4 ms 296 KB Output is correct
25 Correct 19 ms 208 KB Output is correct
26 Correct 15 ms 208 KB Output is correct
27 Correct 4 ms 208 KB Output is correct
28 Correct 23 ms 288 KB Output is correct
29 Correct 13 ms 288 KB Output is correct
30 Correct 37 ms 208 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 7 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 12 ms 256 KB Output is correct
35 Correct 5 ms 208 KB Output is correct
36 Correct 8 ms 208 KB Output is correct
37 Correct 7 ms 208 KB Output is correct
38 Correct 3 ms 292 KB Output is correct
39 Correct 14 ms 292 KB Output is correct
40 Correct 38 ms 208 KB Output is correct
41 Correct 13 ms 292 KB Output is correct
42 Correct 20 ms 208 KB Output is correct
43 Correct 17 ms 208 KB Output is correct
44 Correct 21 ms 208 KB Output is correct
45 Correct 12 ms 288 KB Output is correct
46 Correct 1 ms 292 KB Output is correct
47 Correct 14 ms 296 KB Output is correct
48 Correct 16 ms 208 KB Output is correct
49 Correct 4 ms 208 KB Output is correct
50 Correct 34 ms 208 KB Output is correct
51 Correct 12 ms 344 KB Output is correct
52 Correct 1 ms 284 KB Output is correct
53 Correct 9 ms 292 KB Output is correct
54 Correct 18 ms 288 KB Output is correct
55 Correct 1 ms 292 KB Output is correct
56 Correct 34 ms 268 KB Output is correct
57 Correct 29 ms 292 KB Output is correct
58 Correct 28 ms 208 KB Output is correct
59 Correct 10 ms 292 KB Output is correct
60 Correct 17 ms 208 KB Output is correct
61 Correct 7 ms 208 KB Output is correct
62 Correct 4 ms 288 KB Output is correct
63 Correct 6 ms 220 KB Output is correct
64 Correct 7 ms 292 KB Output is correct
65 Correct 5 ms 292 KB Output is correct
66 Correct 3 ms 208 KB Output is correct
67 Correct 2 ms 208 KB Output is correct
68 Correct 7 ms 208 KB Output is correct
69 Correct 4 ms 208 KB Output is correct
70 Correct 2 ms 208 KB Output is correct
71 Correct 37 ms 208 KB Output is correct
72 Correct 11 ms 208 KB Output is correct
73 Correct 43 ms 208 KB Output is correct
74 Correct 38 ms 208 KB Output is correct
75 Correct 6 ms 208 KB Output is correct
76 Correct 42 ms 208 KB Output is correct
77 Correct 32 ms 208 KB Output is correct
78 Correct 9 ms 292 KB Output is correct
79 Correct 26 ms 208 KB Output is correct
80 Correct 40 ms 208 KB Output is correct
81 Correct 48 ms 284 KB Output is correct
82 Correct 34 ms 336 KB Output is correct
83 Correct 4 ms 208 KB Output is correct
84 Correct 27 ms 208 KB Output is correct
85 Correct 36 ms 208 KB Output is correct
86 Correct 4 ms 208 KB Output is correct
87 Correct 5 ms 208 KB Output is correct
88 Correct 3 ms 336 KB Output is correct
89 Correct 5 ms 208 KB Output is correct
90 Correct 5 ms 208 KB Output is correct
91 Correct 2 ms 292 KB Output is correct
92 Correct 5 ms 336 KB Output is correct
93 Correct 9 ms 208 KB Output is correct
94 Correct 9 ms 208 KB Output is correct
95 Correct 7 ms 208 KB Output is correct
96 Correct 6 ms 208 KB Output is correct
97 Correct 6 ms 208 KB Output is correct