Submission #265180

# Submission time Handle Problem Language Result Execution time Memory
265180 2020-08-14T13:40:41 Z arayi The Big Prize (IOI17_prize) C++17
100 / 100
55 ms 5496 KB
#include "prize.h"
#include <bits/stdc++.h>
#define MP make_pair
#define fr first
#define sc second
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());


const int N = 2e5 + 55;
vector <pair <int, int> > dz;
bool col[N];
int mx, q;
vector <int> ss[N];
int as(int a)
{
    vector <int> fp;
    if(ss[a].size() == 0)
    {
        q++;
        if(q == 9880)
            assert(0);
        fp = ask(a);
        ss[a] = fp;
    }
    else fp = ss[a];
    mx = max(mx, fp[0] + fp[1]);
    if(fp[0] + fp[1] == 0) return 0;
    if(!col[a] && fp[0] + fp[1] < mx)
    {
        dz.push_back(MP(a, fp[0] + fp[1]));
        return 2;
    }
    int sm = 0;
    for(auto p : dz) if(p.fr < a && p.sc < fp[0] + fp[1]) sm++;
    if(fp[0] - sm > 0) return -1;
    return 1;
}

int find_best(int n) {
    for (int i = 0; i < 20; i++)
    {
       int i1 = rnd() % n;
       vector <int> fp = ask(i1);
       mx = max(mx, fp[0] + fp[1]);
    }
    while(true)
    {
        int l = 0, r = n - 1;
        while(l <= r)
        {
            int mid = (l + r)/2;
            int qr = 0;
            while(mid - qr >= 0 && col[mid - qr]) qr++;
            if(mid - qr < 0)
            {
                l = mid + 1;
                continue;
            }
            int sm = as(mid - qr);
            if(sm == 0) return mid - qr;
            if(sm == 2)
            {
                col[mid - qr] = true;
                break;
            }
            if(sm == 1) l = mid + 1;
            if(sm == -1) r = mid - qr - 1;
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Correct 4 ms 4992 KB Output is correct
4 Correct 4 ms 4992 KB Output is correct
5 Correct 4 ms 4992 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 4 ms 4992 KB Output is correct
8 Correct 5 ms 4992 KB Output is correct
9 Correct 7 ms 4992 KB Output is correct
10 Correct 3 ms 4992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 5 ms 4992 KB Output is correct
3 Correct 3 ms 4992 KB Output is correct
4 Correct 4 ms 4992 KB Output is correct
5 Correct 4 ms 4992 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 4 ms 4992 KB Output is correct
8 Correct 4 ms 4992 KB Output is correct
9 Correct 4 ms 4992 KB Output is correct
10 Correct 4 ms 4992 KB Output is correct
11 Correct 5 ms 5112 KB Output is correct
12 Correct 4 ms 4992 KB Output is correct
13 Correct 7 ms 5112 KB Output is correct
14 Correct 5 ms 4992 KB Output is correct
15 Correct 11 ms 5112 KB Output is correct
16 Correct 47 ms 5348 KB Output is correct
17 Correct 5 ms 5072 KB Output is correct
18 Correct 53 ms 5372 KB Output is correct
19 Correct 4 ms 4992 KB Output is correct
20 Correct 12 ms 5120 KB Output is correct
21 Correct 19 ms 5112 KB Output is correct
22 Correct 7 ms 4992 KB Output is correct
23 Correct 4 ms 4992 KB Output is correct
24 Correct 4 ms 4992 KB Output is correct
25 Correct 29 ms 5240 KB Output is correct
26 Correct 21 ms 5204 KB Output is correct
27 Correct 5 ms 4992 KB Output is correct
28 Correct 35 ms 5368 KB Output is correct
29 Correct 30 ms 5244 KB Output is correct
30 Correct 51 ms 5368 KB Output is correct
31 Correct 4 ms 4992 KB Output is correct
32 Correct 8 ms 5112 KB Output is correct
33 Correct 4 ms 4992 KB Output is correct
34 Correct 16 ms 5112 KB Output is correct
35 Correct 6 ms 4992 KB Output is correct
36 Correct 16 ms 5112 KB Output is correct
37 Correct 6 ms 5072 KB Output is correct
38 Correct 4 ms 4992 KB Output is correct
39 Correct 24 ms 5112 KB Output is correct
40 Correct 38 ms 5372 KB Output is correct
41 Correct 29 ms 5216 KB Output is correct
42 Correct 30 ms 5244 KB Output is correct
43 Correct 25 ms 5240 KB Output is correct
44 Correct 20 ms 5112 KB Output is correct
45 Correct 11 ms 5172 KB Output is correct
46 Correct 4 ms 5024 KB Output is correct
47 Correct 25 ms 5164 KB Output is correct
48 Correct 29 ms 5240 KB Output is correct
49 Correct 8 ms 4992 KB Output is correct
50 Correct 53 ms 5356 KB Output is correct
51 Correct 15 ms 5112 KB Output is correct
52 Correct 4 ms 4992 KB Output is correct
53 Correct 4 ms 4992 KB Output is correct
54 Correct 18 ms 5120 KB Output is correct
55 Correct 3 ms 4992 KB Output is correct
56 Correct 35 ms 5368 KB Output is correct
57 Correct 33 ms 5240 KB Output is correct
58 Correct 33 ms 5240 KB Output is correct
59 Correct 28 ms 5240 KB Output is correct
60 Correct 34 ms 5240 KB Output is correct
61 Correct 5 ms 4992 KB Output is correct
62 Correct 4 ms 4992 KB Output is correct
63 Correct 6 ms 5112 KB Output is correct
64 Correct 5 ms 4992 KB Output is correct
65 Correct 5 ms 5076 KB Output is correct
66 Correct 10 ms 4992 KB Output is correct
67 Correct 5 ms 4992 KB Output is correct
68 Correct 9 ms 5024 KB Output is correct
69 Correct 12 ms 4992 KB Output is correct
70 Correct 6 ms 4992 KB Output is correct
71 Correct 39 ms 5368 KB Output is correct
72 Correct 10 ms 5120 KB Output is correct
73 Correct 55 ms 5368 KB Output is correct
74 Correct 50 ms 5368 KB Output is correct
75 Correct 5 ms 4992 KB Output is correct
76 Correct 46 ms 5368 KB Output is correct
77 Correct 42 ms 5368 KB Output is correct
78 Correct 10 ms 5120 KB Output is correct
79 Correct 28 ms 5324 KB Output is correct
80 Correct 55 ms 5420 KB Output is correct
81 Correct 29 ms 5336 KB Output is correct
82 Correct 46 ms 5496 KB Output is correct
83 Correct 5 ms 4992 KB Output is correct
84 Correct 34 ms 5368 KB Output is correct
85 Correct 43 ms 5368 KB Output is correct
86 Correct 20 ms 5248 KB Output is correct
87 Correct 7 ms 5120 KB Output is correct
88 Correct 23 ms 5248 KB Output is correct
89 Correct 23 ms 5280 KB Output is correct
90 Correct 5 ms 4992 KB Output is correct
91 Correct 11 ms 5248 KB Output is correct
92 Correct 7 ms 5120 KB Output is correct
93 Correct 8 ms 5120 KB Output is correct
94 Correct 6 ms 5120 KB Output is correct
95 Correct 7 ms 5120 KB Output is correct
96 Correct 8 ms 5120 KB Output is correct
97 Correct 4 ms 4992 KB Output is correct