답안 #1079308

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

vector<int> dp[200000];

vector<int> myAsk(int n) {
    if (dp[n][0] == -1) dp[n] = ask(n);
    return dp[n];
}

int find_best(int n) {
    for (int i = 0; i < n; i++) {
        dp[i] = {-1, -1};
    }

    int maxi = 0;
    for (int i = 0; i < min(450, n); i++) {
        maxi = max(maxi, myAsk(i)[0] + myAsk(i)[1]);
    }

    int last = 0;
    auto a = myAsk(0);
    if (a[0] + a[1] == 0) return 0;

    int y = n;
    while (y--) {
        cout << last << endl;
        int i1 = last + 1;
        int i2 = n - 1;
        if (myAsk(i1)[0] + myAsk(i1)[1] == maxi) {
            last = i1;
            continue;
        }
        while (i1 != i2) {
            int middle = (i1 + i2) / 2;
            auto a = myAsk(middle);
            if (a[0] + a[1] == 0) return middle;

            if(middle == i1) {
                i1 = i2;
            }else {
                auto b = myAsk(i1);
                if(a[0]-b[0] > 0) {
                    i2 = middle-1;
                }else {
                    i1 = middle;
                }
            }
        }

        auto a = myAsk(i1);
        if (a[0] + a[1] == 0) return i1;
        last = i1;
    }
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:23:21: warning: control reaches end of non-void function [-Wreturn-type]
   23 |     auto a = myAsk(0);
      |                     ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 11352 KB Token "0" doesn't correspond to pattern "[A-B]{1}"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 11352 KB Token "0" doesn't correspond to pattern "[A-B]{1}"
2 Halted 0 ms 0 KB -