| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1351044 | bozho | 커다란 상품 (IOI17_prize) | C++20 | 20 ms | 5480 KiB |
#include <bits/stdc++.h>
#include "prize.h"
#define endl '\n'
using namespace std;
const int MAX = (2e5) + 5;
vector<int> a[MAX];
int p[MAX];
bool d[MAX];
int find_best(int n)
{
random_device rd;
mt19937 rng(rd());
uniform_int_distribution<int> dist(0, n - 1);
int bx = 0, x = 0, id;
for (int i = 0; i < 40; i++)
{
id = dist(rng);
if (!d[id])
{
a[id] = ask(id);
d[id] = 1;
if (a[id][0] + a[id][1] == 0)
return id;
bx = max(bx, a[id][0] + a[id][1]);
}
}
set<int> s;
s.insert(n);
for (int i = 0; i < n; i++)
{
if (!d[i])
{
a[i] = ask(i);
d[i] = 1;
}
x = a[i][0] + a[i][1];
if (x == 0)
return i;
if (x == bx)
{
int l = p[a[i][0]], r = *s.upper_bound(i), mid;
while (r - l > 1)
{
mid = l + (r - l) / 2;
if (!d[mid])
{
a[mid] = ask(mid);
d[i] = 1;
}
if (a[mid][0] + a[mid][1] == 0)
return mid;
if (a[mid][0] + a[mid][1] < bx)
s.insert(a[mid][0] + a[mid][1]);
if(a[mid][0]+a[mid][1] == bx)
p[a[mid][0]] = max(p[a[mid][0]],mid);
if (a[i][0] == a[mid][0] && a[i][1] == a[mid][1])
l = mid;
else
r = mid;
}
i = l;
}
}
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
