Submission #87851

# Submission time Handle Problem Language Result Execution time Memory
87851 2018-12-02T21:27:36 Z KCSC Semiexpress (JOI17_semiexpress) C++14
100 / 100
19 ms 1248 KB
#include <bits/stdc++.h>
using namespace std;

const int DIM = 3005;

long long pos[DIM], cnt[DIM];

int main(void) {
#ifdef HOME
	freopen("semiexpress.in", "r", stdin);
	freopen("semiexpress.out", "w", stdout);
#endif
	long long n, m, k, a, b, c, t;
	cin >> n >> m >> k >> a >> b >> c >> t; k -= m;
	for (int i = 1; i <= m; ++i) {
		cin >> pos[i]; --pos[i];	
		if (t - pos[i] * b < 0) { cnt[i] = -1; }
		else { cnt[i] = (t - pos[i] * b) / a; } }
	cnt[m] = min(cnt[m], 0LL);
	for (int i = 1; i < m; ++i) {
		cnt[i] = min(cnt[i], pos[i + 1] - pos[i] - 1); }
	while (k--) {	
		long long vl = 0, ps = -1;
		for (int i = 1; i < m; ++i) {
			if (t - pos[i] * b - (cnt[i] + 1) * c < 0) {
				continue; }
			long long st = cnt[i] + 1, 
					  en = min(pos[i + 1] - pos[i] - 1, (t - pos[i] * b - st * c) / a + st); 
			if (vl < en - st + 1) {		
				vl = en - st + 1; ps = i; } }
		cnt[ps] += vl; }
	long long ans = -1;	
	for (int i = 1; i <= m; ++i) {
		ans += cnt[i] + 1; }
	cout << ans;  
	return 0; }
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 752 KB Output is correct
4 Correct 2 ms 808 KB Output is correct
5 Correct 2 ms 808 KB Output is correct
6 Correct 2 ms 808 KB Output is correct
7 Correct 2 ms 808 KB Output is correct
8 Correct 2 ms 808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 752 KB Output is correct
4 Correct 2 ms 808 KB Output is correct
5 Correct 2 ms 808 KB Output is correct
6 Correct 2 ms 808 KB Output is correct
7 Correct 2 ms 808 KB Output is correct
8 Correct 2 ms 808 KB Output is correct
9 Correct 2 ms 808 KB Output is correct
10 Correct 2 ms 808 KB Output is correct
11 Correct 2 ms 808 KB Output is correct
12 Correct 2 ms 808 KB Output is correct
13 Correct 2 ms 808 KB Output is correct
14 Correct 2 ms 808 KB Output is correct
15 Correct 2 ms 808 KB Output is correct
16 Correct 2 ms 808 KB Output is correct
17 Correct 2 ms 808 KB Output is correct
18 Correct 2 ms 808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 752 KB Output is correct
4 Correct 2 ms 808 KB Output is correct
5 Correct 2 ms 808 KB Output is correct
6 Correct 2 ms 808 KB Output is correct
7 Correct 2 ms 808 KB Output is correct
8 Correct 2 ms 808 KB Output is correct
9 Correct 2 ms 808 KB Output is correct
10 Correct 2 ms 808 KB Output is correct
11 Correct 2 ms 808 KB Output is correct
12 Correct 2 ms 808 KB Output is correct
13 Correct 2 ms 808 KB Output is correct
14 Correct 2 ms 808 KB Output is correct
15 Correct 2 ms 808 KB Output is correct
16 Correct 2 ms 808 KB Output is correct
17 Correct 2 ms 808 KB Output is correct
18 Correct 2 ms 808 KB Output is correct
19 Correct 6 ms 944 KB Output is correct
20 Correct 8 ms 944 KB Output is correct
21 Correct 3 ms 1012 KB Output is correct
22 Correct 4 ms 1044 KB Output is correct
23 Correct 19 ms 1076 KB Output is correct
24 Correct 3 ms 1096 KB Output is correct
25 Correct 3 ms 1184 KB Output is correct
26 Correct 3 ms 1196 KB Output is correct
27 Correct 3 ms 1216 KB Output is correct
28 Correct 3 ms 1232 KB Output is correct
29 Correct 7 ms 1248 KB Output is correct
30 Correct 5 ms 1248 KB Output is correct