답안 #54019

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54019 2018-07-02T08:28:13 Z chpipis 커다란 상품 (IOI17_prize) C++11
20 / 100
46 ms 1636 KB
#include "prize.h"
#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;

int num_q;
map<int, vi> memo;

vi query(int x) {
    if (memo.count(x)) return memo[x];
    num_q++;
    vi ret = ask(x);
    return memo[x] = ret;
}

int find_best(int n) {
    memo.clear();
    num_q = 0;
    for (int i = 0, j; i < n; i = j + 1) {
        if (i == n - 1) return i;
        j = i;
        vi cur = query(i);
        if (cur[0] + cur[1] == 0) return i;
        int lo = i + 1, hi = n - 1;
        while (lo <= hi) {
            int mid = (lo + hi) >> 1;
            if (query(mid) == cur) {
                lo = mid + 1;
                j = mid;
            } else {
                hi = mid - 1;
            }
        }
    }
    return -1;
}



# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 400 KB Output is correct
7 Correct 2 ms 400 KB Output is correct
8 Correct 2 ms 428 KB Output is correct
9 Correct 2 ms 428 KB Output is correct
10 Correct 2 ms 428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 428 KB Output is correct
2 Correct 2 ms 428 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
4 Correct 2 ms 428 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 2 ms 496 KB Output is correct
7 Correct 2 ms 496 KB Output is correct
8 Correct 2 ms 560 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
10 Correct 2 ms 560 KB Output is correct
11 Correct 6 ms 572 KB Output is correct
12 Correct 2 ms 572 KB Output is correct
13 Correct 8 ms 572 KB Output is correct
14 Correct 5 ms 572 KB Output is correct
15 Correct 20 ms 700 KB Output is correct
16 Incorrect 46 ms 1636 KB Incorrect
17 Halted 0 ms 0 KB -