이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "prize.h"
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
/// #pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
using ii = pair<ll, ll>;
using vi = vector<int>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb lower_bound
const int MOD = 1e9 + 7;
int A[200005][2];
vector<int> query(int k) {
if(A[k][0] != -1)
return {A[k][0], A[k][1]};
return ask(k);
}
int find_best(int N) {
memset(A, -1, sizeof A);
int curr = 0;
for(int l = 0; l < min(N, 474); l++) {
vector<int> V = query(l);
curr = max(curr, V[0] + V[1]);
}
int i = 0;
while(i < N) {
vector<int> V = query(i);
if(V[0] + V[1] == 0) return i;
if(V[0] + V[1] > curr) {
i++; continue;
}
int l = i, r = N - 1, nxt = i;
while(l <= r) {
int md = (l + r + 1) / 2;
vector<int> U = query(md);
if(U[0] == V[0] && U[1] == V[1])
nxt = md, l = md + 1;
else r = md - 1;
}
i = nxt + 1;
}
}
컴파일 시 표준 에러 (stderr) 메시지
prize.cpp: In function 'int find_best(int)':
prize.cpp:53:17: warning: control reaches end of non-void function [-Wreturn-type]
53 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |