Submission #1033899

# Submission time Handle Problem Language Result Execution time Memory
1033899 2024-07-25T07:39:34 Z juicy Semiexpress (JOI17_semiexpress) C++17
100 / 100
3 ms 488 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);

	int N, M, K, A, B, C; long long T; 
	cin >> N >> M >> K >> A >> B >> C >> T;
	vector<int> S(M), pos(M, -1);
	for (int i = 0; i < M; ++i) {
		cin >> S[i];
		--S[i];
		long long X;
		if ((X = T - (long long) B * S[i]) >= 0) {
			pos[i] = min((long long) N, X / A);
		}
	}
	for (int i = 0; i + 1 < M; ++i) {
		pos[i] = min(pos[i], S[i + 1] - S[i] - 1);
	}
	pos[M - 1] = min(pos[M - 1], 0);
	int iter = K - M;
	while (iter--) {
		array<int, 2> best{0, 0};
		for (int i = 0; i + 1 < M; ++i) {
			long long X;
			if ((X = T - (long long) B * S[i] - (long long) C * (pos[i] + 1)) >= 0) {
				long long L = pos[i] + 1, R = min((long long) S[i + 1] - S[i] - 1, L + (X / A));
				best = max(best, {R - L + 1, i});
			}
		}
		pos[best[1]] += best[0];
	}
	cout << accumulate(pos.begin(), pos.end(), 0) + M - 1;
	return 0;
}

// what a "beautiful" problem!

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:36:29: warning: narrowing conversion of '((R - L) + 1)' from 'long long int' to 'int' [-Wnarrowing]
   36 |     best = max(best, {R - L + 1, i});
      |                       ~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 456 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 456 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 360 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 456 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 360 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 3 ms 488 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 1 ms 464 KB Output is correct
30 Correct 1 ms 348 KB Output is correct