답안 #1079195

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1079195 2024-08-28T11:52:52 Z speedcode 커다란 상품 (IOI17_prize) C++17
20 / 100
66 ms 344 KB
#include <bits/stdc++.h>
#include "prize.h"
using namespace std;

int find_best(int n) {
    //binary search the first element each time
    map<int, int> hi;
    hi[n-1] = 0;
    int last = 0;
    auto a = ask(0);
    if (a[0] + a[1] == 0) return 0;
    for (auto k: hi) {
        if (k.first > a[0] + a[1])hi[k.first]++;
    }

    while (true) {
        int i1 = last;
        int i2 = n - 1;
        while (i1 != i2) {
            int middle = (i1 + i2) / 2;
            auto a = ask(middle);
            if (a[0] + a[1] == 0) return middle;

            if (a[0] - hi[a[0] + a[1]] == 0) {
                i1 = middle+1;
            } else {
                i2 = middle - 1;
            }
        }

        auto a = ask(i1);
        if (a[0] + a[1] == 0) return i1;

        last = i1;
        for (auto k: hi) {
            if (k.first > a[0] + a[1])hi[k.first]++;
        }
    }

}


# 결과 실행 시간 메모리 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 0 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 1 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 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 344 KB Output is correct
8 Correct 1 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 66 ms 344 KB Incorrect
12 Halted 0 ms 0 KB -