Submission #1079221

# Submission time Handle Problem Language Result Execution time Memory
1079221 2024-08-28T12:09:51 Z speedcode The Big Prize (IOI17_prize) C++17
20 / 100
69 ms 424 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 (a[0] - hi == 0) {
                if(datMax < n-1) {
                    i1 = middle;
                    i2 = middle;
                }else i1 = middle+1;
            }else {
                i2 = middle;
            }
        }

        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 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 424 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 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 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Incorrect 69 ms 344 KB Incorrect
12 Halted 0 ms 0 KB -