Submission #667186

# Submission time Handle Problem Language Result Execution time Memory
667186 2022-11-30T16:20:44 Z Kahou Semiexpress (JOI17_semiexpress) C++14
100 / 100
133 ms 33300 KB
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mk make_pair
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int maxm = 3050;
ll N, A, B, C, T, S[maxm];
int M, K;
ll ans;
vector<ll> out;

void solve() {
	cin >> N >> M >> K;
	cin >> A >> B >> C;
	cin >> T;
	for (int i = 1; i <= M; i++) {
		cin >> S[i];
	}

	for (int i = 1; i < M; i++) {
		ll E = T-(S[i]-1)*B;
		ll l = S[i];
		ll t = 0;
		while (l < S[i+1] && t <= K && E >= 0) {
			ll dw = l, up = S[i+1];
			while (up - dw > 1) {
				ll md = (up+dw)/2;
				if (E-(md-l)*A < 0) up = md;
				else dw = md;
			}
			if (!t) ans += (up-l);
			else out.push_back(up-l);
			E -= (up-l)*C;
			t++;
			l = up;
		}
	}
	if (T >= (S[M]-1)*B) ans++;
	sort(out.begin(), out.end());
	for (int i = max((int)out.size()-(K-M), 0); i < (int)out.size(); i++) {
		ans += out[i];
	}
	ans--;
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	solve();
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 9 ms 2508 KB Output is correct
22 Correct 7 ms 1444 KB Output is correct
23 Correct 55 ms 8600 KB Output is correct
24 Correct 46 ms 4540 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 100 ms 16836 KB Output is correct
28 Correct 133 ms 33300 KB Output is correct
29 Correct 29 ms 4488 KB Output is correct
30 Correct 12 ms 2512 KB Output is correct