Submission #132757

# Submission time Handle Problem Language Result Execution time Memory
132757 2019-07-19T13:22:00 Z Talant The Big Prize (IOI17_prize) C++17
96.21 / 100
80 ms 24080 KB
#include "prize.h"
#include <bits/stdc++.h>

#define sc second
#define fr first
#define mk make_pair
#define pb push_back

using namespace std;

const int N = (1e6 + 5);
const int inf = (1e9 + 7);

vector <int> res[N];
int mx,cur;

int find_best(int n) {
    for (int i = 0; i < min(n,474); i ++) {
          if (res[i].size() == 0)
          res[i] = ask(i);
          int s = res[i][0] + res[i][1];
          if (!s) return i;
          if (s >= mx) mx = s,cur = i;
    }
    while(1) {
          if (res[cur].size() == 0)
          res[cur] = ask(cur);
          if (res[cur][0] + res[cur][1] == 0) return cur;
          if (res[cur][0] + res[cur][1] != mx) {
                cur ++;
                continue;
          }
          int lf = res[cur][0];
          int rt = res[cur][1];
          int l = cur,r = min(cur + 512,n - 1);
          if (res[r].size() == 0)
            res[r] = ask(r);
          if (res[r][0] + res[r][1] == 0) return r;
          if (res[l] == res[r]) {
            cur = r;
            continue;
          }

          while (r - l > 1) {
                int m = (r + l) >> 1;
                if (res[m].size() == 0)
                      res[m] = ask(m);
                if (res[m][0] + res[m][1] == 0) return m;
                if (res[m][0] == lf && res[m][1] == rt) l = m;
                else r = m;
          }
          if (res[r].size() == 0)
          res[r] = ask(r);
          if (res[r][0] + res[r][1] == 0) return r;
          if (res[r][0] == lf && res[r][1] == rt) l = r;
          cur = l + 1;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 29 ms 23800 KB Output is correct
2 Correct 33 ms 23800 KB Output is correct
3 Correct 30 ms 23800 KB Output is correct
4 Correct 33 ms 23800 KB Output is correct
5 Correct 30 ms 23800 KB Output is correct
6 Correct 24 ms 23672 KB Output is correct
7 Correct 30 ms 23800 KB Output is correct
8 Correct 30 ms 23800 KB Output is correct
9 Correct 27 ms 23824 KB Output is correct
10 Correct 29 ms 23912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 23800 KB Output is correct
2 Correct 32 ms 23800 KB Output is correct
3 Correct 29 ms 23800 KB Output is correct
4 Correct 31 ms 23800 KB Output is correct
5 Correct 27 ms 23824 KB Output is correct
6 Correct 24 ms 23788 KB Output is correct
7 Correct 29 ms 23800 KB Output is correct
8 Correct 32 ms 23800 KB Output is correct
9 Correct 32 ms 23804 KB Output is correct
10 Correct 31 ms 23800 KB Output is correct
11 Correct 33 ms 23716 KB Output is correct
12 Correct 28 ms 23800 KB Output is correct
13 Correct 30 ms 23840 KB Output is correct
14 Correct 30 ms 23800 KB Output is correct
15 Correct 35 ms 23800 KB Output is correct
16 Correct 69 ms 23948 KB Output is correct
17 Correct 28 ms 23724 KB Output is correct
18 Partially correct 79 ms 23884 KB Partially correct - number of queries: 5358
19 Correct 28 ms 23800 KB Output is correct
20 Correct 46 ms 23800 KB Output is correct
21 Correct 48 ms 23800 KB Output is correct
22 Correct 31 ms 23808 KB Output is correct
23 Correct 27 ms 23816 KB Output is correct
24 Correct 26 ms 23944 KB Output is correct
25 Correct 53 ms 23896 KB Output is correct
26 Correct 47 ms 23884 KB Output is correct
27 Correct 31 ms 23800 KB Output is correct
28 Partially correct 50 ms 23960 KB Partially correct - number of queries: 5280
29 Correct 45 ms 23916 KB Output is correct
30 Partially correct 79 ms 23892 KB Partially correct - number of queries: 5242
31 Correct 35 ms 23800 KB Output is correct
32 Correct 29 ms 24080 KB Output is correct
33 Correct 23 ms 23788 KB Output is correct
34 Correct 44 ms 23800 KB Output is correct
35 Correct 31 ms 23800 KB Output is correct
36 Correct 40 ms 23800 KB Output is correct
37 Correct 30 ms 23800 KB Output is correct
38 Correct 45 ms 23800 KB Output is correct
39 Correct 49 ms 23928 KB Output is correct
40 Correct 57 ms 23864 KB Output is correct
41 Correct 53 ms 23896 KB Output is correct
42 Correct 60 ms 23800 KB Output is correct
43 Correct 56 ms 23888 KB Output is correct
44 Correct 48 ms 23804 KB Output is correct
45 Correct 44 ms 23868 KB Output is correct
46 Correct 33 ms 23800 KB Output is correct
47 Correct 51 ms 23800 KB Output is correct
48 Correct 44 ms 24044 KB Output is correct
49 Correct 33 ms 23800 KB Output is correct
50 Partially correct 77 ms 23932 KB Partially correct - number of queries: 5376
51 Correct 45 ms 23944 KB Output is correct
52 Correct 30 ms 23800 KB Output is correct
53 Correct 36 ms 23800 KB Output is correct
54 Correct 49 ms 23800 KB Output is correct
55 Correct 26 ms 23816 KB Output is correct
56 Partially correct 75 ms 23928 KB Partially correct - number of queries: 5363
57 Correct 50 ms 23992 KB Output is correct
58 Correct 61 ms 23916 KB Output is correct
59 Correct 60 ms 23848 KB Output is correct
60 Correct 55 ms 23860 KB Output is correct
61 Correct 34 ms 23804 KB Output is correct
62 Correct 30 ms 23800 KB Output is correct
63 Correct 33 ms 23800 KB Output is correct
64 Correct 31 ms 23800 KB Output is correct
65 Correct 34 ms 23800 KB Output is correct
66 Correct 37 ms 23820 KB Output is correct
67 Correct 28 ms 23824 KB Output is correct
68 Correct 30 ms 23800 KB Output is correct
69 Correct 38 ms 23800 KB Output is correct
70 Correct 28 ms 23824 KB Output is correct
71 Partially correct 70 ms 23868 KB Partially correct - number of queries: 5030
72 Correct 34 ms 23720 KB Output is correct
73 Correct 76 ms 23896 KB Output is correct
74 Correct 63 ms 23948 KB Output is correct
75 Correct 35 ms 23800 KB Output is correct
76 Correct 69 ms 23988 KB Output is correct
77 Partially correct 72 ms 23904 KB Partially correct - number of queries: 5367
78 Correct 44 ms 23800 KB Output is correct
79 Correct 45 ms 23796 KB Output is correct
80 Partially correct 70 ms 24056 KB Partially correct - number of queries: 5346
81 Partially correct 76 ms 23908 KB Partially correct - number of queries: 5379
82 Partially correct 80 ms 23900 KB Partially correct - number of queries: 5301
83 Correct 37 ms 23800 KB Output is correct
84 Correct 75 ms 23880 KB Output is correct
85 Partially correct 75 ms 23928 KB Partially correct - number of queries: 5301
86 Correct 34 ms 23800 KB Output is correct
87 Correct 33 ms 23800 KB Output is correct
88 Correct 33 ms 23800 KB Output is correct
89 Correct 33 ms 23800 KB Output is correct
90 Correct 33 ms 23800 KB Output is correct
91 Correct 34 ms 23932 KB Output is correct
92 Correct 35 ms 23800 KB Output is correct
93 Correct 30 ms 23828 KB Output is correct
94 Correct 49 ms 23892 KB Output is correct
95 Correct 38 ms 23800 KB Output is correct
96 Correct 29 ms 23900 KB Output is correct
97 Correct 33 ms 23800 KB Output is correct