답안 #1117038

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1117038 2024-11-22T19:10:48 Z Zflop 쌀 창고 (IOI11_ricehub) C++14
100 / 100
15 ms 5712 KB
#include <bits/stdc++.h>
using namespace std;
 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
const int NMAX = (int)1e5 * 2;
long long pref_val[NMAX],suf_val[NMAX];
int besthub(int R, int L, int X[], long long B) {
	for (int i = 0; i < R;++i) {
		pref_val[i] = X[i];
		if (i) {
			pref_val[i] += pref_val[i - 1];
			} 
		}
	for (int i = R - 1; i >= 0;--i) {
		suf_val[i] = suf_val[i + 1] + L - X[i];
		}
	
	int l = 1,r = R;
	int ans = 1;
	while (l <= r) {
		long long mid = (l + r) / 2;
		//cout << mid << ' ' << "here\n";
		bool ok = false;
		for (long long i = 0; i < R - mid + 1;++i) {
			long long id = i + mid / 2;
			long long left_part = suf_val[i] - suf_val[id] - (id - i) * (L - X[id]);
			long long right_part = pref_val[i + mid - 1] - pref_val[id] - (mid - (id - i) - 1) * X[id];
			long long cost = left_part + right_part;
			//cout << cost << ' ' << mid << ' ' << left_part << ' ' << right_part << '\n';
			if (cost <= B) 
				ok = true;
			}
		if (ok) {
			ans = mid;
			l = mid + 1;
			}
		else 
			r = mid - 1;
		}
	return ans;
	}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4432 KB Output is correct
2 Correct 1 ms 4604 KB Output is correct
3 Correct 1 ms 4432 KB Output is correct
4 Correct 1 ms 4432 KB Output is correct
5 Correct 1 ms 4432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4432 KB Output is correct
2 Correct 1 ms 4432 KB Output is correct
3 Correct 1 ms 4432 KB Output is correct
4 Correct 1 ms 4432 KB Output is correct
5 Correct 1 ms 4604 KB Output is correct
6 Correct 1 ms 4432 KB Output is correct
7 Correct 1 ms 4432 KB Output is correct
8 Correct 1 ms 4432 KB Output is correct
9 Correct 1 ms 4432 KB Output is correct
10 Correct 1 ms 4600 KB Output is correct
11 Correct 1 ms 4432 KB Output is correct
12 Correct 1 ms 4432 KB Output is correct
13 Correct 1 ms 4432 KB Output is correct
14 Correct 1 ms 4432 KB Output is correct
15 Correct 1 ms 4432 KB Output is correct
16 Correct 1 ms 4432 KB Output is correct
17 Correct 1 ms 4432 KB Output is correct
18 Correct 1 ms 4432 KB Output is correct
19 Correct 1 ms 4432 KB Output is correct
20 Correct 1 ms 4432 KB Output is correct
21 Correct 1 ms 4432 KB Output is correct
22 Correct 1 ms 4432 KB Output is correct
23 Correct 1 ms 4432 KB Output is correct
24 Correct 1 ms 4432 KB Output is correct
25 Correct 1 ms 4432 KB Output is correct
26 Correct 1 ms 4432 KB Output is correct
27 Correct 1 ms 4432 KB Output is correct
28 Correct 1 ms 4600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4432 KB Output is correct
2 Correct 1 ms 4432 KB Output is correct
3 Correct 2 ms 4608 KB Output is correct
4 Correct 1 ms 4432 KB Output is correct
5 Correct 2 ms 4604 KB Output is correct
6 Correct 1 ms 4432 KB Output is correct
7 Correct 1 ms 4432 KB Output is correct
8 Correct 1 ms 4432 KB Output is correct
9 Correct 1 ms 4432 KB Output is correct
10 Correct 1 ms 4432 KB Output is correct
11 Correct 2 ms 4432 KB Output is correct
12 Correct 1 ms 4432 KB Output is correct
13 Correct 1 ms 4432 KB Output is correct
14 Correct 1 ms 4432 KB Output is correct
15 Correct 1 ms 4432 KB Output is correct
16 Correct 2 ms 4432 KB Output is correct
17 Correct 1 ms 4432 KB Output is correct
18 Correct 1 ms 4432 KB Output is correct
19 Correct 1 ms 4432 KB Output is correct
20 Correct 1 ms 4432 KB Output is correct
21 Correct 2 ms 4432 KB Output is correct
22 Correct 1 ms 4432 KB Output is correct
23 Correct 2 ms 4432 KB Output is correct
24 Correct 2 ms 4432 KB Output is correct
25 Correct 1 ms 4432 KB Output is correct
26 Correct 1 ms 4432 KB Output is correct
27 Correct 1 ms 4432 KB Output is correct
28 Correct 1 ms 4548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4860 KB Output is correct
2 Correct 4 ms 4544 KB Output is correct
3 Correct 10 ms 4688 KB Output is correct
4 Correct 10 ms 4540 KB Output is correct
5 Correct 7 ms 4944 KB Output is correct
6 Correct 10 ms 5200 KB Output is correct
7 Correct 11 ms 5456 KB Output is correct
8 Correct 9 ms 5456 KB Output is correct
9 Correct 6 ms 5112 KB Output is correct
10 Correct 6 ms 4944 KB Output is correct
11 Correct 10 ms 5712 KB Output is correct
12 Correct 12 ms 5604 KB Output is correct
13 Correct 7 ms 4944 KB Output is correct
14 Correct 7 ms 4944 KB Output is correct
15 Correct 8 ms 5456 KB Output is correct
16 Correct 11 ms 5456 KB Output is correct
17 Correct 15 ms 5448 KB Output is correct
18 Correct 10 ms 5456 KB Output is correct
19 Correct 10 ms 5712 KB Output is correct
20 Correct 10 ms 5676 KB Output is correct