Submission #163419

# Submission time Handle Problem Language Result Execution time Memory
163419 2019-11-13T08:59:01 Z iefnah06 Semiexpress (JOI17_semiexpress) C++11
100 / 100
4 ms 508 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int MAXM = 3010;
const int MAXK = 3010;
ll N;
int M, K;
ll A, B, C;
ll T;
ll S[MAXM];

ll pos[MAXM];

// covers [l, r)
ll go(ll x, ll l, ll m) {
	ll r = (T - x * (B - C) - l * (C - A) + B) / A + 1;
	r = max(r, l);
	r = min(r, m);
	return r;
}

ll go(int ind) {
	return go(S[ind], pos[ind], S[ind+1]);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> M >> K;
	cin >> A >> B >> C;
	cin >> T;
	for (int i = 0; i < M; i++) {
		cin >> S[i];
	}
	ll ans = 0;
	priority_queue<pair<ll, int>> cnds; // {length, index}
	for (int i = 0; i < M-1; i++) {
		pos[i] = S[i];
		pos[i] = go(i);
		ans += pos[i] - S[i];
		cnds.emplace(go(i) - pos[i], i);
	}
	for (int t = 0; t < K - M; t++) {
		ll l; int ind; tie(l, ind) = cnds.top();
		cnds.pop();
		ans += l;
		pos[ind] += l;
		cnds.emplace(go(ind) - pos[ind], ind);
	}
	if (B * (N-1) > T) ans--;
	cout << ans << '\n';

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 3 ms 504 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 2 ms 424 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 3 ms 504 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 3 ms 504 KB Output is correct
27 Correct 3 ms 504 KB Output is correct
28 Correct 2 ms 508 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct