답안 #306751

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
306751 2020-09-26T08:40:07 Z syy 쌀 창고 (IOI11_ricehub) C++17
100 / 100
26 ms 3328 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll n, arr[100005], ss[100005], budget;

bool ok(ll k) {
	FOR(i, 1, n-k+1) {
		ll m = (i + i+k-1)/2;
		if (budget >= (ss[i+k-1] - ss[m] - arr[m]*(i+k-1-m)) + (arr[m]*(m-i) - (ss[m-1] - ss[i-1]))) return 1;
	}
	return 0;
}

int besthub(int R, int L, int X[], ll B) {
	n = R, budget = B;
	FOR(i, 1, n) arr[i] = X[i-1];
	FOR(i, 1, n) ss[i] = ss[i-1] + arr[i];
	ll lower = 1, upper = n+1;
	while (upper - lower > 1) {
		ll mid = (upper + lower)/2;
		if (ok(mid)) lower = mid;
		else upper = mid;
	}
	return (int) lower;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 388 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 288 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 416 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 436 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 2 ms 508 KB Output is correct
24 Correct 1 ms 504 KB Output is correct
25 Correct 2 ms 512 KB Output is correct
26 Correct 2 ms 512 KB Output is correct
27 Correct 2 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 768 KB Output is correct
2 Correct 6 ms 896 KB Output is correct
3 Correct 26 ms 3328 KB Output is correct
4 Correct 21 ms 3328 KB Output is correct
5 Correct 9 ms 1664 KB Output is correct
6 Correct 10 ms 1664 KB Output is correct
7 Correct 17 ms 3072 KB Output is correct
8 Correct 17 ms 3072 KB Output is correct
9 Correct 12 ms 1536 KB Output is correct
10 Correct 10 ms 1536 KB Output is correct
11 Correct 21 ms 3328 KB Output is correct
12 Correct 21 ms 3328 KB Output is correct
13 Correct 15 ms 1664 KB Output is correct
14 Correct 11 ms 1664 KB Output is correct
15 Correct 16 ms 2560 KB Output is correct
16 Correct 20 ms 2560 KB Output is correct
17 Correct 18 ms 3064 KB Output is correct
18 Correct 24 ms 3072 KB Output is correct
19 Correct 25 ms 3192 KB Output is correct
20 Correct 20 ms 3200 KB Output is correct