Submission #1079242

# Submission time Handle Problem Language Result Execution time Memory
1079242 2024-08-28T12:17:06 Z speedcode The Big Prize (IOI17_prize) C++17
20 / 100
67 ms 596 KB
#include <bits/stdc++.h>
#include "prize.h"
using namespace std;

int find_best(int n) {
    //binary search the first element each time
    int hi = 0;
    int last = 0;
    auto a = ask(0);
    if (a[0] + a[1] == 0) return 0;
    int datMax = a[0] + a[1];
    int thatAreMax = 1;
    while (true) {
        int i1 = last;
        int i2 = n - 1;
        while (i1 != i2) {
            int middle = ceil(((double)i1 + i2) / 2.0);
            auto a = ask(middle);
            if (a[0] + a[1] == 0) return middle;
            if(a[0] + a[1] > datMax) {
                datMax = a[0] + a[1];
                hi += thatAreMax;
                thatAreMax = 0;
            }
            if(i2-i1 > 1) {
                if (a[0] - hi == 0) {
                    if(a[0] + a[1] < datMax) {
                        i1 = middle;
                        i2 = middle;
                    }else i1 = middle+1;
                }else {
                    i2 = middle;
                }
            }else {
                auto b = ask(i1);
                if(b[0]+b[1] < a[0]+a[1]) {
                    i2 = i1;
                }else i1 = i2;
            }
        }

        auto a = ask(i1);
        if (a[0] + a[1] == 0) return i1;
        last = i1;
        if(a[0] + a[1] > datMax) {
            datMax = a[0] + a[1];
            hi += thatAreMax;
            thatAreMax = 0;
        }
        if (a[0] + a[1] < datMax) hi++;
        else thatAreMax++;

    }

}


# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 432 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 424 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 4 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 7 ms 432 KB Output is correct
16 Partially correct 40 ms 428 KB Partially correct - number of queries: 7258
17 Correct 0 ms 344 KB Output is correct
18 Partially correct 50 ms 344 KB Partially correct - number of queries: 8528
19 Correct 0 ms 344 KB Output is correct
20 Correct 11 ms 344 KB Output is correct
21 Correct 20 ms 344 KB Output is correct
22 Correct 3 ms 432 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 22 ms 344 KB Output is correct
26 Correct 32 ms 428 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Partially correct 38 ms 344 KB Partially correct - number of queries: 8114
29 Partially correct 30 ms 344 KB Partially correct - number of queries: 6153
30 Partially correct 47 ms 344 KB Partially correct - number of queries: 8451
31 Correct 1 ms 344 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 13 ms 432 KB Output is correct
35 Correct 2 ms 344 KB Output is correct
36 Correct 13 ms 344 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 17 ms 428 KB Output is correct
40 Partially correct 39 ms 344 KB Partially correct - number of queries: 7225
41 Partially correct 24 ms 340 KB Partially correct - number of queries: 5084
42 Partially correct 20 ms 344 KB Partially correct - number of queries: 5084
43 Correct 28 ms 344 KB Output is correct
44 Correct 19 ms 344 KB Output is correct
45 Correct 18 ms 428 KB Output is correct
46 Correct 0 ms 596 KB Output is correct
47 Correct 16 ms 344 KB Output is correct
48 Partially correct 34 ms 344 KB Partially correct - number of queries: 6302
49 Correct 5 ms 596 KB Output is correct
50 Partially correct 48 ms 344 KB Partially correct - number of queries: 8479
51 Correct 14 ms 344 KB Output is correct
52 Correct 1 ms 344 KB Output is correct
53 Correct 1 ms 344 KB Output is correct
54 Correct 26 ms 344 KB Output is correct
55 Correct 0 ms 344 KB Output is correct
56 Partially correct 38 ms 344 KB Partially correct - number of queries: 8509
57 Partially correct 36 ms 344 KB Partially correct - number of queries: 6232
58 Partially correct 37 ms 596 KB Partially correct - number of queries: 6321
59 Partially correct 23 ms 344 KB Partially correct - number of queries: 5086
60 Correct 32 ms 344 KB Output is correct
61 Correct 1 ms 344 KB Output is correct
62 Correct 1 ms 344 KB Output is correct
63 Correct 1 ms 344 KB Output is correct
64 Correct 1 ms 344 KB Output is correct
65 Correct 3 ms 344 KB Output is correct
66 Correct 13 ms 344 KB Output is correct
67 Correct 1 ms 344 KB Output is correct
68 Correct 6 ms 344 KB Output is correct
69 Correct 6 ms 344 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
71 Partially correct 47 ms 344 KB Partially correct - number of queries: 9216
72 Correct 3 ms 344 KB Output is correct
73 Partially correct 42 ms 344 KB Partially correct - number of queries: 9089
74 Partially correct 41 ms 344 KB Partially correct - number of queries: 9136
75 Correct 1 ms 344 KB Output is correct
76 Partially correct 39 ms 344 KB Partially correct - number of queries: 7847
77 Partially correct 38 ms 344 KB Partially correct - number of queries: 8676
78 Correct 4 ms 344 KB Output is correct
79 Correct 18 ms 344 KB Output is correct
80 Partially correct 55 ms 344 KB Partially correct - number of queries: 8672
81 Partially correct 42 ms 344 KB Partially correct - number of queries: 8639
82 Partially correct 56 ms 344 KB Partially correct - number of queries: 8579
83 Correct 1 ms 344 KB Output is correct
84 Partially correct 29 ms 344 KB Partially correct - number of queries: 7100
85 Partially correct 67 ms 344 KB Partially correct - number of queries: 8602
86 Incorrect 53 ms 344 KB Incorrect
87 Halted 0 ms 0 KB -