답안 #1060903

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1060903 2024-08-16T04:17:35 Z onbert 커다란 상품 (IOI17_prize) C++17
20 / 100
13 ms 22616 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5;
vector<int> vals[maxn];
vector<int> qry(int i) {
    if (vals[i][0]!=-1) return vals[i];
    else return vals[i] = ask(i);
}
int find_best(int n) {
    for (int i=0;i<n;i++) vals[i] = {-1, -1};
    int mx = 0;
    for (int i=0;i<n;i++) {
        vector<int> x = qry(i);
        mx = max(x[0]+x[1], mx);
        if (x[0] + x[1] == 0) return i;
        int l = i, r = n-1;
        while (l<r && x[0]+x[1] == mx) {
            int mid = (l+r+1)/2;
            vector<int> y = qry(mid);
            mx = max(y[0]+y[1], mx);
            if (y[0]+y[1]==0) return mid;
            if (y[0]!=x[0] || y[1]!=x[1]) r = mid-1;
            else l = mid;
        }
        i = r;
    }
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:28:1: warning: control reaches end of non-void function [-Wreturn-type]
   28 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 11352 KB Output is correct
2 Correct 8 ms 11352 KB Output is correct
3 Correct 11 ms 11352 KB Output is correct
4 Correct 7 ms 11352 KB Output is correct
5 Correct 8 ms 11352 KB Output is correct
6 Correct 8 ms 11352 KB Output is correct
7 Correct 10 ms 11352 KB Output is correct
8 Correct 7 ms 11352 KB Output is correct
9 Correct 7 ms 11352 KB Output is correct
10 Correct 7 ms 11352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 11352 KB Output is correct
2 Correct 7 ms 11352 KB Output is correct
3 Correct 8 ms 11352 KB Output is correct
4 Correct 9 ms 11352 KB Output is correct
5 Correct 9 ms 11348 KB Output is correct
6 Correct 8 ms 11352 KB Output is correct
7 Correct 8 ms 11352 KB Output is correct
8 Correct 7 ms 11352 KB Output is correct
9 Correct 8 ms 11352 KB Output is correct
10 Correct 8 ms 11352 KB Output is correct
11 Runtime error 13 ms 22616 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -