답안 #432563

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
432563 2021-06-18T11:08:58 Z plekkpea 커다란 상품 (IOI17_prize) C++14
100 / 100
70 ms 11300 KB
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> kaes[200005];
ll su,ma=0,x;

int rek(ll l,ll r,ll a,ll b){
    if(r<l || l<0 ) return -1;
    ll k=(l+r)/2,x,arv;
    bool en=0,par=0;
    if(kaes[k][0]==-1) kaes[k]=ask(k);
    if(kaes[k][0]+kaes[k][1]==0) return k;
    x=k;
    if(kaes[x][0]==a) en=1;
    if(kaes[x][0]==b) par=1;
    while(kaes[x][0]+kaes[x][1]<su){
        x++;
        if(x==r+1) break;
        if(kaes[x][0]==-1) kaes[x]=ask(x);
        if(kaes[x][0]+kaes[x][1]==0) return x;
        if(kaes[x][0]==a) en=1;
        if(kaes[x][0]==b) par=1;
    }
    if(x==r+1){
        x=k;
        while(kaes[x][0]+kaes[x][1]<su){
            x--;
            if(x==l-1) break;
            if(kaes[x][0]==-1) kaes[x]=ask(x);
            if(kaes[x][0]+kaes[x][1]==0) return x;
            if(kaes[x][0]==a) en=1;
            if(kaes[x][0]==b) par=1;
        }
    }
    if(x<l) return -1;
    if(!en){
        if(x<=k) arv=rek(l,x-1,a,kaes[x][0]);
        else arv=rek(l,k-1,a,kaes[x][0]-(x-k));
        if(arv!=-1) return arv;
    }
    if(!par){
        if(x>=k) arv=rek(x+1,r,kaes[x][0],b);
        else arv=rek(k+1,r,kaes[x][0]-(k-x),b);
        if(arv!=-1) return arv;
    }
    return -1;
}

int find_best(int n) {
    ll l=0, r=n-1;
    vector<int> res;
    for(int i=0; i<10; i++){
        x=(rand())%n;
        res=ask(x);
        su=res[0]+res[1];
        kaes[x]=res;
        ma=max(ma,su);
        if(su==0) return x;
    }
    for(int i=0; i<n; i++) kaes[i].resize(2),kaes[i][0]=-1;
    return rek(l,r,0,su);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 11224 KB Output is correct
2 Correct 21 ms 11128 KB Output is correct
3 Correct 17 ms 11236 KB Output is correct
4 Correct 17 ms 11120 KB Output is correct
5 Correct 18 ms 11120 KB Output is correct
6 Correct 20 ms 11116 KB Output is correct
7 Correct 21 ms 11104 KB Output is correct
8 Correct 20 ms 11116 KB Output is correct
9 Correct 17 ms 11112 KB Output is correct
10 Correct 18 ms 11228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 11160 KB Output is correct
2 Correct 20 ms 11124 KB Output is correct
3 Correct 19 ms 11176 KB Output is correct
4 Correct 19 ms 11200 KB Output is correct
5 Correct 22 ms 11300 KB Output is correct
6 Correct 17 ms 11200 KB Output is correct
7 Correct 18 ms 11124 KB Output is correct
8 Correct 17 ms 11120 KB Output is correct
9 Correct 22 ms 11124 KB Output is correct
10 Correct 22 ms 11152 KB Output is correct
11 Correct 19 ms 11176 KB Output is correct
12 Correct 16 ms 11204 KB Output is correct
13 Correct 21 ms 11120 KB Output is correct
14 Correct 10 ms 5576 KB Output is correct
15 Correct 29 ms 11200 KB Output is correct
16 Correct 54 ms 11152 KB Output is correct
17 Correct 20 ms 11184 KB Output is correct
18 Correct 63 ms 11120 KB Output is correct
19 Correct 21 ms 11228 KB Output is correct
20 Correct 23 ms 8052 KB Output is correct
21 Correct 35 ms 11128 KB Output is correct
22 Correct 23 ms 11108 KB Output is correct
23 Correct 19 ms 11124 KB Output is correct
24 Correct 20 ms 11120 KB Output is correct
25 Correct 37 ms 11120 KB Output is correct
26 Correct 40 ms 11112 KB Output is correct
27 Correct 23 ms 11200 KB Output is correct
28 Correct 69 ms 11116 KB Output is correct
29 Correct 43 ms 11200 KB Output is correct
30 Correct 58 ms 11208 KB Output is correct
31 Correct 16 ms 11108 KB Output is correct
32 Correct 18 ms 11192 KB Output is correct
33 Correct 5 ms 4992 KB Output is correct
34 Correct 34 ms 11116 KB Output is correct
35 Correct 21 ms 11200 KB Output is correct
36 Correct 25 ms 11232 KB Output is correct
37 Correct 21 ms 11200 KB Output is correct
38 Correct 21 ms 11124 KB Output is correct
39 Correct 38 ms 11116 KB Output is correct
40 Correct 52 ms 11108 KB Output is correct
41 Correct 53 ms 11200 KB Output is correct
42 Correct 38 ms 11160 KB Output is correct
43 Correct 38 ms 11180 KB Output is correct
44 Correct 39 ms 11120 KB Output is correct
45 Correct 30 ms 11104 KB Output is correct
46 Correct 20 ms 11200 KB Output is correct
47 Correct 42 ms 11120 KB Output is correct
48 Correct 46 ms 11200 KB Output is correct
49 Correct 23 ms 11192 KB Output is correct
50 Correct 62 ms 11124 KB Output is correct
51 Correct 30 ms 11208 KB Output is correct
52 Correct 16 ms 11200 KB Output is correct
53 Correct 18 ms 11200 KB Output is correct
54 Correct 45 ms 11132 KB Output is correct
55 Correct 17 ms 11200 KB Output is correct
56 Correct 61 ms 11120 KB Output is correct
57 Correct 55 ms 11120 KB Output is correct
58 Correct 57 ms 11128 KB Output is correct
59 Correct 45 ms 11108 KB Output is correct
60 Correct 42 ms 11200 KB Output is correct
61 Correct 22 ms 11116 KB Output is correct
62 Correct 16 ms 11200 KB Output is correct
63 Correct 22 ms 11124 KB Output is correct
64 Correct 18 ms 11208 KB Output is correct
65 Correct 17 ms 11200 KB Output is correct
66 Correct 26 ms 11120 KB Output is correct
67 Correct 22 ms 11216 KB Output is correct
68 Correct 19 ms 11116 KB Output is correct
69 Correct 20 ms 11120 KB Output is correct
70 Correct 24 ms 11124 KB Output is correct
71 Correct 60 ms 11208 KB Output is correct
72 Correct 24 ms 11136 KB Output is correct
73 Correct 65 ms 11240 KB Output is correct
74 Correct 63 ms 11164 KB Output is correct
75 Correct 21 ms 11208 KB Output is correct
76 Correct 61 ms 11192 KB Output is correct
77 Correct 67 ms 11188 KB Output is correct
78 Correct 22 ms 11208 KB Output is correct
79 Correct 40 ms 11200 KB Output is correct
80 Correct 70 ms 11208 KB Output is correct
81 Correct 42 ms 11124 KB Output is correct
82 Correct 64 ms 11168 KB Output is correct
83 Correct 17 ms 11244 KB Output is correct
84 Correct 49 ms 11208 KB Output is correct
85 Correct 45 ms 11196 KB Output is correct
86 Correct 23 ms 11208 KB Output is correct
87 Correct 22 ms 11184 KB Output is correct
88 Correct 23 ms 11144 KB Output is correct
89 Correct 22 ms 11120 KB Output is correct
90 Correct 18 ms 11252 KB Output is correct
91 Correct 19 ms 11208 KB Output is correct
92 Correct 16 ms 11128 KB Output is correct
93 Correct 25 ms 11156 KB Output is correct
94 Correct 19 ms 11208 KB Output is correct
95 Correct 19 ms 11208 KB Output is correct
96 Correct 18 ms 11208 KB Output is correct
97 Correct 16 ms 11208 KB Output is correct