Submission #289637

# Submission time Handle Problem Language Result Execution time Memory
289637 2020-09-02T20:25:22 Z peti1234 The Big Prize (IOI17_prize) C++17
100 / 100
51 ms 2980 KB
#include <bits/stdc++.h>
#include "prize.h";
using namespace std;
const int c=200005;
int ert[c], bal[c], jobb[c], maxi, valasz, el, p;
bool v[c];
void kerd(int a) {
    if (v[a]) return;
    v[a]=1;
    vector<int> sz=ask(a-1);
    bal[a]=sz[0], jobb[a]=sz[1];
    p=bal[a]+jobb[a], ert[a]=p;
    if (!p) valasz=a-1;
    maxi=max(maxi, p);
}
void solve(int a, int b) {
    if (!v[a]) kerd(a);
    if (!v[b]) kerd(b);
    int db=jobb[a]-jobb[b];
    if (db) {
        int m=(a+b)/2, kis=m+1, nagy=m-1, p=0;
        while(p!=maxi && kis>a) {
            kis--, kerd(kis);
            p=ert[kis];
        }
        p=0;
        if (kis!=a) solve(a, kis);
        while(p!=maxi && nagy<b) {
            nagy++, kerd(nagy);
            p=ert[nagy];
        }
        if (nagy!=b) solve(nagy, b);
    }
}
int find_best(int n) {
    if (n<5000) {
        for (int i=1; i<=n; i++) kerd(i);
        return valasz;
    }
    int r=n/500;
    for (int i=1; i<=500; i++) kerd(i*r);
    v[0]=1, v[n+1]=1;
    jobb[0]=maxi, bal[n+1]=maxi, ert[0]=maxi, ert[n+1]=maxi;
    for (int i=1; i<=500; i++) if (ert[i*r]==maxi) solve(el, i*r), el=i*r;
    solve(el, n+1);
    return valasz;
}

Compilation message

prize.cpp:2:19: warning: extra tokens at end of #include directive
    2 | #include "prize.h";
      |                   ^
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2808 KB Output is correct
2 Correct 7 ms 2816 KB Output is correct
3 Correct 7 ms 2812 KB Output is correct
4 Correct 4 ms 2868 KB Output is correct
5 Correct 9 ms 2816 KB Output is correct
6 Correct 6 ms 2816 KB Output is correct
7 Correct 6 ms 2808 KB Output is correct
8 Correct 7 ms 2808 KB Output is correct
9 Correct 6 ms 2808 KB Output is correct
10 Correct 7 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2848 KB Output is correct
2 Correct 7 ms 2816 KB Output is correct
3 Correct 7 ms 2816 KB Output is correct
4 Correct 6 ms 2816 KB Output is correct
5 Correct 7 ms 2848 KB Output is correct
6 Correct 6 ms 2816 KB Output is correct
7 Correct 7 ms 2808 KB Output is correct
8 Correct 7 ms 2816 KB Output is correct
9 Correct 7 ms 2796 KB Output is correct
10 Correct 7 ms 2816 KB Output is correct
11 Correct 6 ms 2860 KB Output is correct
12 Correct 6 ms 2860 KB Output is correct
13 Correct 8 ms 2808 KB Output is correct
14 Correct 15 ms 640 KB Output is correct
15 Correct 41 ms 2816 KB Output is correct
16 Correct 41 ms 2808 KB Output is correct
17 Correct 44 ms 2808 KB Output is correct
18 Correct 43 ms 2816 KB Output is correct
19 Correct 50 ms 2816 KB Output is correct
20 Correct 30 ms 1664 KB Output is correct
21 Correct 47 ms 2808 KB Output is correct
22 Correct 34 ms 2816 KB Output is correct
23 Correct 8 ms 2816 KB Output is correct
24 Correct 10 ms 2808 KB Output is correct
25 Correct 29 ms 2816 KB Output is correct
26 Correct 37 ms 2816 KB Output is correct
27 Correct 10 ms 2808 KB Output is correct
28 Correct 26 ms 2944 KB Output is correct
29 Correct 36 ms 2816 KB Output is correct
30 Correct 44 ms 2816 KB Output is correct
31 Correct 41 ms 2816 KB Output is correct
32 Correct 9 ms 2816 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 41 ms 2808 KB Output is correct
35 Correct 8 ms 2816 KB Output is correct
36 Correct 41 ms 2944 KB Output is correct
37 Correct 6 ms 2864 KB Output is correct
38 Correct 7 ms 2816 KB Output is correct
39 Correct 43 ms 2808 KB Output is correct
40 Correct 35 ms 2816 KB Output is correct
41 Correct 41 ms 2808 KB Output is correct
42 Correct 26 ms 2860 KB Output is correct
43 Correct 25 ms 2860 KB Output is correct
44 Correct 51 ms 2804 KB Output is correct
45 Correct 39 ms 2808 KB Output is correct
46 Correct 43 ms 2816 KB Output is correct
47 Correct 46 ms 2808 KB Output is correct
48 Correct 30 ms 2816 KB Output is correct
49 Correct 47 ms 2808 KB Output is correct
50 Correct 46 ms 2808 KB Output is correct
51 Correct 45 ms 2808 KB Output is correct
52 Correct 42 ms 2816 KB Output is correct
53 Correct 8 ms 2808 KB Output is correct
54 Correct 39 ms 2808 KB Output is correct
55 Correct 45 ms 2808 KB Output is correct
56 Correct 49 ms 2808 KB Output is correct
57 Correct 49 ms 2808 KB Output is correct
58 Correct 42 ms 2808 KB Output is correct
59 Correct 42 ms 2808 KB Output is correct
60 Correct 45 ms 2808 KB Output is correct
61 Correct 8 ms 2808 KB Output is correct
62 Correct 8 ms 2816 KB Output is correct
63 Correct 10 ms 2808 KB Output is correct
64 Correct 8 ms 2808 KB Output is correct
65 Correct 7 ms 2808 KB Output is correct
66 Correct 11 ms 2808 KB Output is correct
67 Correct 11 ms 2816 KB Output is correct
68 Correct 10 ms 2808 KB Output is correct
69 Correct 11 ms 2808 KB Output is correct
70 Correct 8 ms 2808 KB Output is correct
71 Correct 38 ms 2816 KB Output is correct
72 Correct 9 ms 2816 KB Output is correct
73 Correct 40 ms 2816 KB Output is correct
74 Correct 43 ms 2816 KB Output is correct
75 Correct 10 ms 2816 KB Output is correct
76 Correct 39 ms 2944 KB Output is correct
77 Correct 48 ms 2816 KB Output is correct
78 Correct 11 ms 2816 KB Output is correct
79 Correct 21 ms 2816 KB Output is correct
80 Correct 41 ms 2788 KB Output is correct
81 Correct 39 ms 2940 KB Output is correct
82 Correct 33 ms 2944 KB Output is correct
83 Correct 9 ms 2816 KB Output is correct
84 Correct 49 ms 2816 KB Output is correct
85 Correct 44 ms 2816 KB Output is correct
86 Correct 29 ms 2816 KB Output is correct
87 Correct 12 ms 2812 KB Output is correct
88 Correct 30 ms 2816 KB Output is correct
89 Correct 21 ms 2824 KB Output is correct
90 Correct 8 ms 2976 KB Output is correct
91 Correct 28 ms 2816 KB Output is correct
92 Correct 36 ms 2816 KB Output is correct
93 Correct 42 ms 2816 KB Output is correct
94 Correct 42 ms 2816 KB Output is correct
95 Correct 43 ms 2816 KB Output is correct
96 Correct 43 ms 2816 KB Output is correct
97 Correct 31 ms 2980 KB Output is correct