Submission #355532

# Submission time Handle Problem Language Result Execution time Memory
355532 2021-01-22T16:40:24 Z SeDunion Semiexpress (JOI17_semiexpress) C++17
100 / 100
9 ms 492 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 66;

int x[N];
ll d[N];

/*
10 3 5
10 3 5
30
1
6
10

di
0 10 20 30 40 15 25 35 45 27



*/

int s[N];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	ll A, B, C, T;
	cin >> A >> B >> C >> T;
	int ans = 0;
	for (int i = 1 ; i <= m ; ++ i) {
		cin >> x[i];
	}
	for (int i = 2 ; i <= m ; ++ i) {
		if ((x[i] - 1) * B <= T) ans++;
		int l = x[i - 1], r = x[i];
		ll cost = (x[i - 1] - 1) * B;
		s[i] = l + 1;
		if (cost > T) continue;
		ll rem = T - cost;
		ll cnt = rem / A;
		cnt = min(cnt, r - l - 1ll);
		ans += cnt;
		s[i] = l + cnt + 1;
	}
	for (; m < k ; -- k) {
		pair<ll,int> mx = {-1, -1};
		for (int i = 2 ; i <= m ; ++ i) {
			int l = s[i], r = x[i];
			if (l >= r) continue;
			ll cost = (x[i - 1] - 1) * B + (s[i] - x[i - 1]) * C;
			if (cost > T) continue;
			ll rem = T - cost;
			ll cnt = rem / A + 1;
			cnt = min(cnt, r - l - 0ll);
			mx = max(mx, {cnt, i});
		}
		if (mx.first == -1) break;
		s[mx.second] += mx.first;
		ans += mx.first;
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 9 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 492 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 2 ms 364 KB Output is correct
30 Correct 2 ms 364 KB Output is correct