Submission #535432

# Submission time Handle Problem Language Result Execution time Memory
535432 2022-03-10T09:22:51 Z mario05092929 The Big Prize (IOI17_prize) C++14
100 / 100
77 ms 12132 KB
#include "prize.h"
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair <int,int> pi;
typedef vector <int> vec;
using namespace std;
vector <int> g[435];
int di = 473,m,n,pmx,la,big;
vec d[200005];

vec getAsk(int x) {
    if(d[x][0] != -1) return d[x];
    return d[x] = ask(x);
}

int find_best(int N) {
    n = N; m = n/di+(n%di>0);
    for(int i = 0;i < n;i++) d[i].push_back(-1), d[i].push_back(-1);
    for(int i = 0;i < m;i++) {
        for(int j = i*di;j < min(n,i*di+di);j++) g[i].push_back(j);
    }
    int cn = 0;
    for(int i = 0;i < m&&cn < di;i++,cn++) {
        vec tmp = getAsk(g[i].back());
        pmx = max(pmx,tmp[0]+tmp[1]);
    }
    for(int i = 0;i < n&&cn < di;i++,cn++) {
        vec tmp = getAsk(i);
        pmx = max(pmx,tmp[0]+tmp[1]);
    }
    la = -1;
    for(int i = 0;i < m;) {
        //cout << i << ' ' << la << '\n';
        vec tmp = getAsk(g[i].back());
        if(la == g[i].back()) {
            i++; continue;
        }
        if(tmp[0]+tmp[1] == pmx&&tmp[0] == big) {
            i++; continue;
        }
        la = max(la+1,g[i][0]);
        int l = la,r = g[i].back();
        int wi = -1;
        while(l <= r) {
            int mid = (l + r) >> 1;
            vec t = getAsk(mid);
            if(t[0]+t[1] != pmx) wi = mid;
            if(t[0]+t[1] != pmx||t[0] != big) r = mid-1;
            else l = mid+1;
        }
        if(wi == -1) while(1);
        vec t2 = getAsk(wi);
        if(t2[0]+t2[1] == pmx) while(1);
        if(t2[0]+t2[1] == 0) return wi;
        la = wi;
        big++;
    }
    return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 26 ms 12020 KB Output is correct
2 Correct 27 ms 12024 KB Output is correct
3 Correct 33 ms 12032 KB Output is correct
4 Correct 25 ms 12112 KB Output is correct
5 Correct 33 ms 12080 KB Output is correct
6 Correct 26 ms 11988 KB Output is correct
7 Correct 26 ms 12108 KB Output is correct
8 Correct 26 ms 12104 KB Output is correct
9 Correct 40 ms 12028 KB Output is correct
10 Correct 34 ms 12012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 12028 KB Output is correct
2 Correct 24 ms 12104 KB Output is correct
3 Correct 24 ms 12044 KB Output is correct
4 Correct 33 ms 12020 KB Output is correct
5 Correct 46 ms 12072 KB Output is correct
6 Correct 24 ms 12040 KB Output is correct
7 Correct 26 ms 12040 KB Output is correct
8 Correct 25 ms 12064 KB Output is correct
9 Correct 35 ms 12040 KB Output is correct
10 Correct 26 ms 12104 KB Output is correct
11 Correct 33 ms 12036 KB Output is correct
12 Correct 25 ms 12036 KB Output is correct
13 Correct 33 ms 12028 KB Output is correct
14 Correct 10 ms 5712 KB Output is correct
15 Correct 36 ms 12040 KB Output is correct
16 Correct 59 ms 12044 KB Output is correct
17 Correct 27 ms 12024 KB Output is correct
18 Correct 65 ms 12092 KB Output is correct
19 Correct 28 ms 12024 KB Output is correct
20 Correct 21 ms 8488 KB Output is correct
21 Correct 43 ms 12028 KB Output is correct
22 Correct 32 ms 11988 KB Output is correct
23 Correct 27 ms 12096 KB Output is correct
24 Correct 28 ms 12060 KB Output is correct
25 Correct 50 ms 11992 KB Output is correct
26 Correct 51 ms 12028 KB Output is correct
27 Correct 32 ms 12020 KB Output is correct
28 Correct 60 ms 12024 KB Output is correct
29 Correct 71 ms 12036 KB Output is correct
30 Correct 64 ms 12104 KB Output is correct
31 Correct 34 ms 12028 KB Output is correct
32 Correct 26 ms 12032 KB Output is correct
33 Correct 4 ms 4944 KB Output is correct
34 Correct 33 ms 12024 KB Output is correct
35 Correct 26 ms 12032 KB Output is correct
36 Correct 30 ms 12056 KB Output is correct
37 Correct 29 ms 12032 KB Output is correct
38 Correct 31 ms 12032 KB Output is correct
39 Correct 47 ms 12032 KB Output is correct
40 Correct 76 ms 12036 KB Output is correct
41 Correct 52 ms 12020 KB Output is correct
42 Correct 43 ms 12036 KB Output is correct
43 Correct 56 ms 12004 KB Output is correct
44 Correct 29 ms 12040 KB Output is correct
45 Correct 33 ms 12104 KB Output is correct
46 Correct 36 ms 12056 KB Output is correct
47 Correct 57 ms 12076 KB Output is correct
48 Correct 56 ms 12004 KB Output is correct
49 Correct 39 ms 12032 KB Output is correct
50 Correct 66 ms 12032 KB Output is correct
51 Correct 51 ms 12020 KB Output is correct
52 Correct 23 ms 12028 KB Output is correct
53 Correct 25 ms 12028 KB Output is correct
54 Correct 47 ms 12024 KB Output is correct
55 Correct 32 ms 11988 KB Output is correct
56 Correct 57 ms 12032 KB Output is correct
57 Correct 37 ms 12000 KB Output is correct
58 Correct 40 ms 12028 KB Output is correct
59 Correct 46 ms 12096 KB Output is correct
60 Correct 53 ms 11996 KB Output is correct
61 Correct 26 ms 12100 KB Output is correct
62 Correct 22 ms 12020 KB Output is correct
63 Correct 25 ms 12036 KB Output is correct
64 Correct 34 ms 12020 KB Output is correct
65 Correct 29 ms 12020 KB Output is correct
66 Correct 24 ms 12032 KB Output is correct
67 Correct 25 ms 12088 KB Output is correct
68 Correct 34 ms 12092 KB Output is correct
69 Correct 29 ms 12032 KB Output is correct
70 Correct 25 ms 12104 KB Output is correct
71 Correct 39 ms 12004 KB Output is correct
72 Correct 28 ms 12112 KB Output is correct
73 Correct 70 ms 12052 KB Output is correct
74 Correct 57 ms 12028 KB Output is correct
75 Correct 23 ms 12112 KB Output is correct
76 Correct 71 ms 12096 KB Output is correct
77 Correct 65 ms 12044 KB Output is correct
78 Correct 25 ms 12104 KB Output is correct
79 Correct 41 ms 11984 KB Output is correct
80 Correct 71 ms 12124 KB Output is correct
81 Correct 57 ms 12104 KB Output is correct
82 Correct 44 ms 12076 KB Output is correct
83 Correct 25 ms 12040 KB Output is correct
84 Correct 47 ms 11996 KB Output is correct
85 Correct 51 ms 12112 KB Output is correct
86 Correct 62 ms 12032 KB Output is correct
87 Correct 26 ms 12132 KB Output is correct
88 Correct 53 ms 12128 KB Output is correct
89 Correct 50 ms 12112 KB Output is correct
90 Correct 30 ms 12116 KB Output is correct
91 Correct 41 ms 12004 KB Output is correct
92 Correct 51 ms 12040 KB Output is correct
93 Correct 57 ms 11976 KB Output is correct
94 Correct 59 ms 12112 KB Output is correct
95 Correct 52 ms 12012 KB Output is correct
96 Correct 77 ms 12036 KB Output is correct
97 Correct 47 ms 12132 KB Output is correct