답안 #765515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
765515 2023-06-24T16:44:51 Z NK_ Semiexpress (JOI17_semiexpress) C++17
100 / 100
2 ms 468 KB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'
#define pb push_back
#define sz(x) int(x.size())

using ll = long long;
template<class T> using V = vector<T>;

int main() {
	cin.tie(0)->sync_with_stdio(0);
		
	int N, M, K; cin >> N >> M >> K;
	ll A, B, C; cin >> A >> B >> C;

	ll T; cin >> T;

	V<int> S(M); for(auto& x : S) cin >> x;
	S.pb(N + 1);

	K -= M;

	set<array<ll, 5>> opt;

	int ans = 0;

	for(int i = 0; i < M; i++) {
		int L = S[i], R = S[i+1];
		ll t = (S[i] - 1) * 1LL * B;

		// t + kA <= T
		// kA <= T - t;
		if (T >= t) {
			ll k = (T - t) / A;
			int l = min(L + k + 1, R + 0LL);
			// cout << t << " " << k << " " << L << " " << l << " " << R << endl;
			ans += l - L;

			ll tl = t + (l - L) * C;
			if (T >= tl) {
				// cout << tl << endl;
				ll k_ = (T - tl) / A;
				int can = min(l + k_ + 1, R + 0LL);
				// cout << k_ << " " << can << endl;
				if (can > l) opt.insert({can - l, tl, l, L, R});
			}
		}
	}

	// cout << endl;

	while(K--) { 
		if (sz(opt) == 0) break;
		auto [add, t, l, L, R] = *rbegin(opt); opt.erase(prev(end(opt)));

		// cout << add << " " << t << " " << l << " " << L << " " << R << endl;

		ans += add;
		l += add;

		ll tl = t + add * C;
		// c << tl << endl;
		if (T >= tl) {
			ll k_ = (T - tl) / A;
			int can = min(l + k_ + 1, R + 0LL);
			// cout << k_ << " " << can << endl;
			if (can > l) opt.insert({can - l, tl, l, L, R});
		}
	}

	cout << ans - 1 << nl;
    return 0;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 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 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 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 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 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 320 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 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 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 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 320 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 320 KB Output is correct
30 Correct 1 ms 212 KB Output is correct