제출 #659217

#제출 시각아이디문제언어결과실행 시간메모리
659217jiahng커다란 상품 (IOI17_prize)C++14
90 / 100
91 ms5408 KiB
#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]; } int find_best(int n) { N = n; pi lollipop = pi(-1,-1); FOR(i,0,min(N-1,499)){ 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){ DEC(i,30,0) if (x + (1<<i) < 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...