이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 200010
#define INF (ll)1e9
#define MOD 1000000007
typedef pair <vi, int> pvi;
typedef pair <int,pi> ipi;
typedef vector <pii> vpii;
int N;
vi memo[maxn];
vi query(int x){
if (memo[x].empty()) memo[x] = ask(x);
return memo[x];
}
const int sqrtn = 472;
int find_best(int n) {
N = n;
pi lollipop = pi(-1,-1);
FOR(i,0,min(N-1,sqrtn)){
vi v = query(i);
lollipop = max(lollipop, pi(v[0] + v[1], -i));
}
lollipop.s *= -1;
int x = lollipop.s;
int tar = lollipop.s;
vi non_lollipops;
FOR(i,0,x-1) non_lollipops.pb(i);
while (x < N){
int start = x;
DEC(i,30,0) if (x + (1<<i) < min(start + sqrtn, N)){
vi v = query(x+(1<<i));
if (v[0] == tar && v[0] + v[1] == lollipop.f) x += (1 << i);
}
x++;
while (x < N){
vi v = query(x);
if (v[0] + v[1] == lollipop.f) break;
non_lollipops.pb(x); x++; tar++;
}
}
aFOR(i, non_lollipops){
//cout << i << ' ';
vi v = query(i);
if (v[0] + v[1] == 0) return i;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |