답안 #1117037

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1117037 2024-11-22T19:09:31 Z Zflop 쌀 창고 (IOI11_ricehub) C++14
68 / 100
10 ms 4688 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) {
		int mid = (l + r) / 2;
		//cout << mid << ' ' << "here\n";
		bool ok = false;
		for (int i = 0; i < R - mid + 1;++i) {
			int 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 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 2 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 4432 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 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 2 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 4600 KB Output is correct
20 Correct 2 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 2 ms 4600 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 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 4432 KB Output is correct
6 Correct 1 ms 4432 KB Output is correct
7 Correct 1 ms 4600 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 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 4600 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 2 ms 4432 KB Output is correct
28 Correct 2 ms 4432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4688 KB Output is correct
2 Correct 3 ms 4688 KB Output is correct
3 Correct 9 ms 4688 KB Output is correct
4 Incorrect 10 ms 4688 KB Output isn't correct
5 Halted 0 ms 0 KB -