답안 #511322

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
511322 2022-01-15T14:23:29 Z AdamGS 쌀 창고 (IOI11_ricehub) C++14
100 / 100
22 ms 3300 KB
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e5+7;
ll sum[LIM], T[LIM];
ll Q(int l, int r) {
	return sum[r]-(l?sum[l-1]:0);
}
int besthub(int n, int m, int P[], long long b) {
	rep(i, n) {
		if(i) sum[i]=sum[i-1];
		T[i]=P[i];
		sum[i]+=T[i];
	}
	ll ans=1;
	rep(i, n) {
		ll p=0, k=min(i, n-i-1);
		while(p<k) {
			ll sr=(p+k+1)/2;
			if(Q(i+1, i+sr)-Q(i-sr, i-1)<=b) p=sr; else k=sr-1;
		}
		ans=max(ans, 2*p+1);
	}
	for(int i=1; i<n; ++i) {
		ll p=0, k=min(i-1, n-i-1);
		while(p<k) {
			ll sr=(p+k+1)/2;
			if(Q(i+1, i+sr)-Q(i-sr-1, i-1)+T[i]<=b) p=sr; else k=sr-1;
		}
		if(T[i]-T[i-1]<=b) ans=max(ans, 2*p+2);
	}
	rep(i, n-1) {
		ll p=0, k=min(i, n-i-2);
		while(p<k) {
			ll sr=(p+k+1)/2;
			if(Q(i+1, i+sr+1)-Q(i-sr, i-1)-T[i]<=b) p=sr; else k=sr-1;
		}
		if(T[i+1]-T[i]<=b) ans=max(ans, 2*p+2);
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 300 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 304 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 300 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 304 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 1 ms 312 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 308 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 420 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 816 KB Output is correct
2 Correct 4 ms 716 KB Output is correct
3 Correct 19 ms 3276 KB Output is correct
4 Correct 20 ms 3200 KB Output is correct
5 Correct 11 ms 1604 KB Output is correct
6 Correct 12 ms 1624 KB Output is correct
7 Correct 19 ms 2948 KB Output is correct
8 Correct 17 ms 2884 KB Output is correct
9 Correct 11 ms 1580 KB Output is correct
10 Correct 14 ms 1556 KB Output is correct
11 Correct 20 ms 3204 KB Output is correct
12 Correct 22 ms 3300 KB Output is correct
13 Correct 9 ms 1624 KB Output is correct
14 Correct 10 ms 1588 KB Output is correct
15 Correct 15 ms 2464 KB Output is correct
16 Correct 14 ms 2500 KB Output is correct
17 Correct 16 ms 2848 KB Output is correct
18 Correct 17 ms 2936 KB Output is correct
19 Correct 17 ms 3148 KB Output is correct
20 Correct 19 ms 3124 KB Output is correct