Submission #668128

# Submission time Handle Problem Language Result Execution time Memory
668128 2022-12-02T21:06:56 Z finn__ The Big Prize (IOI17_prize) C++17
90 / 100
87 ms 5308 KB
#include <bits/stdc++.h>
#include "prize.h"
using namespace std;

int find_best(int n)
{
    int ans_max = 0;
    vector<vector<int>> v(n);

    for (size_t i = 0; i < min(n, 474); i++)
    {
        v[i] = ask(i);
        ans_max = max(ans_max, v[i][0] + v[i][1]);

        if (!v[i][0] && !v[i][1])
            return i;
    }

    int i = -1, found = 0;

    while (1)
    {
        int a = i + 1, b = n - 1;

        while (a < b)
        {
            int mid = (a + b) / 2;
            if (v[mid].empty())
                v[mid] = ask(mid);

            if (!v[mid][0] && !v[mid][1])
                return mid;

            if (v[mid][0] + v[mid][1] == ans_max)
            {
                if (v[mid][0] == found)
                    a = mid + 1;
                else
                    b = mid;
            }
            else
                b = mid;
        }

        found++;
        i = a;

        if (v[i].empty())
            v[i] = ask(i);
        if (!v[i][0] && !v[i][1])
            return i;
    }
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:10:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'const int' [-Wsign-compare]
   10 |     for (size_t i = 0; i < min(n, 474); i++)
      |                        ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4944 KB Output is correct
2 Correct 6 ms 4900 KB Output is correct
3 Correct 6 ms 4896 KB Output is correct
4 Correct 6 ms 4944 KB Output is correct
5 Correct 8 ms 4944 KB Output is correct
6 Correct 3 ms 4896 KB Output is correct
7 Correct 5 ms 5020 KB Output is correct
8 Correct 6 ms 4900 KB Output is correct
9 Correct 6 ms 4896 KB Output is correct
10 Correct 8 ms 4944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 5004 KB Output is correct
2 Correct 7 ms 4900 KB Output is correct
3 Correct 5 ms 4896 KB Output is correct
4 Correct 4 ms 5020 KB Output is correct
5 Correct 5 ms 4944 KB Output is correct
6 Correct 2 ms 4944 KB Output is correct
7 Correct 7 ms 4892 KB Output is correct
8 Correct 5 ms 5064 KB Output is correct
9 Correct 7 ms 5020 KB Output is correct
10 Correct 8 ms 4944 KB Output is correct
11 Correct 12 ms 4896 KB Output is correct
12 Correct 10 ms 5000 KB Output is correct
13 Correct 13 ms 5020 KB Output is correct
14 Correct 9 ms 816 KB Output is correct
15 Correct 15 ms 4944 KB Output is correct
16 Partially correct 57 ms 5148 KB Partially correct - number of queries: 6974
17 Correct 7 ms 5020 KB Output is correct
18 Partially correct 65 ms 5180 KB Partially correct - number of queries: 8094
19 Correct 7 ms 4900 KB Output is correct
20 Correct 23 ms 2680 KB Output is correct
21 Correct 30 ms 5016 KB Output is correct
22 Correct 11 ms 4944 KB Output is correct
23 Correct 6 ms 5016 KB Output is correct
24 Correct 6 ms 5004 KB Output is correct
25 Correct 49 ms 5024 KB Output is correct
26 Correct 44 ms 5164 KB Output is correct
27 Correct 7 ms 4944 KB Output is correct
28 Partially correct 60 ms 5204 KB Partially correct - number of queries: 7686
29 Partially correct 25 ms 5164 KB Partially correct - number of queries: 5923
30 Partially correct 66 ms 5232 KB Partially correct - number of queries: 8017
31 Correct 5 ms 4936 KB Output is correct
32 Correct 10 ms 4944 KB Output is correct
33 Correct 0 ms 208 KB Output is correct
34 Correct 24 ms 5016 KB Output is correct
35 Correct 6 ms 4900 KB Output is correct
36 Correct 19 ms 5020 KB Output is correct
37 Correct 6 ms 5072 KB Output is correct
38 Correct 6 ms 4896 KB Output is correct
39 Correct 34 ms 5016 KB Output is correct
40 Partially correct 72 ms 5208 KB Partially correct - number of queries: 6935
41 Partially correct 43 ms 5144 KB Partially correct - number of queries: 5045
42 Partially correct 43 ms 5064 KB Partially correct - number of queries: 5045
43 Correct 41 ms 5060 KB Output is correct
44 Correct 31 ms 5044 KB Output is correct
45 Correct 32 ms 5060 KB Output is correct
46 Correct 6 ms 4896 KB Output is correct
47 Correct 32 ms 5036 KB Output is correct
48 Partially correct 35 ms 5292 KB Partially correct - number of queries: 6125
49 Correct 10 ms 4944 KB Output is correct
50 Partially correct 53 ms 5236 KB Partially correct - number of queries: 8074
51 Correct 40 ms 5016 KB Output is correct
52 Correct 6 ms 4944 KB Output is correct
53 Correct 9 ms 4904 KB Output is correct
54 Correct 17 ms 5108 KB Output is correct
55 Correct 7 ms 4896 KB Output is correct
56 Partially correct 65 ms 5180 KB Partially correct - number of queries: 8071
57 Partially correct 46 ms 5112 KB Partially correct - number of queries: 6004
58 Partially correct 51 ms 5060 KB Partially correct - number of queries: 6101
59 Partially correct 42 ms 5064 KB Partially correct - number of queries: 5045
60 Correct 22 ms 5188 KB Output is correct
61 Correct 8 ms 4904 KB Output is correct
62 Correct 7 ms 4944 KB Output is correct
63 Correct 8 ms 4936 KB Output is correct
64 Correct 7 ms 4900 KB Output is correct
65 Correct 8 ms 4900 KB Output is correct
66 Correct 9 ms 5028 KB Output is correct
67 Correct 7 ms 4904 KB Output is correct
68 Correct 7 ms 4944 KB Output is correct
69 Correct 13 ms 5032 KB Output is correct
70 Correct 6 ms 4892 KB Output is correct
71 Partially correct 51 ms 5240 KB Partially correct - number of queries: 8281
72 Correct 11 ms 4944 KB Output is correct
73 Partially correct 81 ms 5184 KB Partially correct - number of queries: 8178
74 Partially correct 65 ms 5196 KB Partially correct - number of queries: 8227
75 Correct 6 ms 5084 KB Output is correct
76 Partially correct 44 ms 5308 KB Partially correct - number of queries: 7112
77 Partially correct 35 ms 5160 KB Partially correct - number of queries: 8141
78 Correct 9 ms 5016 KB Output is correct
79 Correct 19 ms 5016 KB Output is correct
80 Partially correct 65 ms 5144 KB Partially correct - number of queries: 8141
81 Partially correct 74 ms 5212 KB Partially correct - number of queries: 8132
82 Partially correct 47 ms 5260 KB Partially correct - number of queries: 8053
83 Correct 10 ms 4900 KB Output is correct
84 Partially correct 66 ms 5164 KB Partially correct - number of queries: 6713
85 Partially correct 87 ms 5140 KB Partially correct - number of queries: 8126
86 Correct 46 ms 5016 KB Output is correct
87 Correct 7 ms 5076 KB Output is correct
88 Correct 29 ms 5028 KB Output is correct
89 Correct 35 ms 5024 KB Output is correct
90 Correct 8 ms 4944 KB Output is correct
91 Correct 27 ms 5016 KB Output is correct
92 Correct 18 ms 5008 KB Output is correct
93 Correct 34 ms 5148 KB Output is correct
94 Correct 42 ms 5064 KB Output is correct
95 Correct 37 ms 5028 KB Output is correct
96 Correct 27 ms 5072 KB Output is correct
97 Correct 39 ms 5044 KB Output is correct