# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
728122 | nguyentunglam | 커다란 상품 (IOI17_prize) | C++17 | 71 ms | 5308 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#include "prize.h"
//mt19937 rng(172831923);
////mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//int rnd(int l, int r) {
// return l + rng() % (r - l + 1);
//}
const int N = 2e5 + 10;
vector<int> ans[N];
int worst;
int check(int i, int j) {
if (ans[i].empty()) ans[i] = ask(i); if (ans[j].empty()) ans[j] = ask(j);
if (ans[j][0] + ans[j][1] != worst) return 2;
int tmp = ans[i][1] + ans[j][0] - worst;
return tmp > 0;
}
int find_best(int n) {
int T = max(1, n / 785);
for(int i = 0; i < n; i += T) {
ans[i] = ask(i);
worst = max(worst, ans[i][0] + ans[i][1]);
}
for(int i = 1; i < n; i++) if (i % T) {
if (ans[i].empty()) ans[i] = ask(i);
if (ans[i][0] + ans[i][1] != worst) continue;
int l = i, r = n - 1;
for(int j = T; j < n; j += T) if (j > i) {
if (check(i, j)) {
r = j;
break;
}
l = j;
}
int last = l;
while (l <= r) {
int mid = l + r >> 1;
int tmp = check(i, mid);
if (!tmp) {
last = mid;
l = mid + 1;
}
else r = mid - 1;
}
// cout << i << " " << last << endl;
i = last;
}
for(int i = 0; i < n; i++) if (!ans[i].empty() && ans[i][0] + ans[i][1] == 0) {
return i;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |