답안 #235860

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
235860 2020-05-30T08:06:52 Z Dilshod_Imomov 쌀 창고 (IOI11_ricehub) C++17
68 / 100
133 ms 1656 KB
#include "ricehub.h"	
#include <bits/stdc++.h>
using namespace std;
# define LL long long

long long ps[100100];

int besthub(int n, int mx, int a[], long long b)
{
	for ( LL i = 0; i < n; i++ ) {
		ps[i] = a[i];
		if ( i ) {
			ps[i] += ps[i - 1];
		}
	}
	LL ans = 1;
	for ( LL i = 0; i < n; i++ ) {
		LL x = a[i];
		LL l = i, r = n - 1, mid;
		while ( l <= r ) {
			mid = (l + r) / 2;
			long long sum = ps[mid] - ps[i];
			sum -= (mid - i) * x;
			long long left = b - sum;
			if ( left < 0 ) {
				r = mid - 1;
			}
			else {
				ans = max( ans, mid - i + 1 );
				LL ll = 0, rr = i - 1, mid1, ind = i;
				while ( ll <= rr ) {
					mid1 = (ll + rr) / 2;
					long long sum1 = ps[i - 1];
					if ( mid1 ) {
						sum1 -= ps[mid1 - 1];
					}
					sum1 = (i - mid1) * x - sum1;
					if ( sum1 > left ) {
						ll = mid1 + 1;
					}
					else {
						rr = mid1 - 1;
						ind = mid1;
						ans = max( ans, (mid - i) + (i - ind) + 1 );
					}
				}
				ans = max( ans, (mid - i) + (i - ind) + 1 );
				l = mid + 1;
			}
		}
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 7 ms 384 KB Output is correct
22 Correct 7 ms 384 KB Output is correct
23 Correct 7 ms 384 KB Output is correct
24 Correct 8 ms 384 KB Output is correct
25 Correct 8 ms 384 KB Output is correct
26 Correct 8 ms 384 KB Output is correct
27 Correct 8 ms 384 KB Output is correct
28 Correct 8 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 512 KB Output is correct
2 Correct 11 ms 640 KB Output is correct
3 Correct 94 ms 1656 KB Output is correct
4 Correct 125 ms 1536 KB Output is correct
5 Correct 23 ms 896 KB Output is correct
6 Correct 23 ms 896 KB Output is correct
7 Correct 99 ms 1536 KB Output is correct
8 Correct 111 ms 1536 KB Output is correct
9 Correct 44 ms 896 KB Output is correct
10 Correct 44 ms 896 KB Output is correct
11 Correct 95 ms 1544 KB Output is correct
12 Correct 133 ms 1536 KB Output is correct
13 Incorrect 27 ms 896 KB Output isn't correct
14 Halted 0 ms 0 KB -