이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define fr first
#define sc second
//#define int long long
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int xmax = 500;
const int blocksize = 400;
int maxi = 0, cnt = 1;
int find_best(int n) {
for(int i=0;i<min(n, xmax);i++){
vector<int>arr = ask(i);
maxi = max(maxi, arr[0] + arr[1]);
}
int blockcurr = 0, ok = -1;
while(blockcurr <= (n - 1)/blocksize){
int l, r;
if(ok == -1){
l = blockcurr * blocksize;
}
else{
l = ok + 1;
ok = -1;
}
r = min(n - 1, (blockcurr + 1) * blocksize - 1);
while(l <= r){
int mid = l + (r - l) / 2;
vector<int>rs = ask(mid);
if((rs[0] + rs[1]) == maxi){
if(rs[0] >= cnt){
r = mid - 1;
}
else{
l = mid + 1;
}
}
else{
if(!(rs[0] + rs[1])){
return mid;
}
ok = mid;
r = mid - 1;
}
}
if(ok == -1){
blockcurr++;
}
else{
cnt++;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
prize.cpp: In function 'int find_best(int)':
prize.cpp:64:1: warning: control reaches end of non-void function [-Wreturn-type]
64 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |