Submission #355520

# Submission time Handle Problem Language Result Execution time Memory
355520 2021-01-22T15:56:59 Z SeDunion Semiexpress (JOI17_semiexpress) C++17
48 / 100
29 ms 24812 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 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];
	}
	int l = 1;
	//cout << "di\n";
	for (int i = 1 ; i <= n ; ++ i) {
		while (x[l] < i) ++l;
		d[i] = ll(1e18);
		if (x[l] == i) d[i] = (i - 1) * B;
		d[i] = min(d[i], d[i - 1] + A);
		//cout << d[i] << " ";
	}
	//cout << "\n";
	vector<int> g;
	for (int i = 2 ; i <= m ; ++ i) {
		if (d[x[i]] <= T) ans++;
		int l = x[i - 1], r = x[i];
		int cur = 0;
		ll cost = ll(1e18);
		for (int j = l + 1 ; j < r ; ++ j) {
			if (d[j] <= T) {
				ans++;
				continue;
			}
			if (d[j] + (j - l) * (C - A) > T) {
				continue;
			}
			cost += A;
			if (cost > T) {
				g.push_back(cur);
				cost = d[j] + (j - l) * (C - A);
				cur = 0;
			}
			cur++;
		}
		g.push_back(cur);
	}
	sort(g.begin(), g.end());
	while (g.size() && k > m) {
		k--;
		ans += g.back();
		g.pop_back();
	}
	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 364 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 364 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 364 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 364 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 364 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 Runtime error 29 ms 24812 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -