답안 #654286

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
654286 2022-10-30T21:09:16 Z Farbod Semiexpress (JOI17_semiexpress) C++17
100 / 100
2 ms 340 KB
/*
*  In the name of God
*
*  Author: Farbod Doost
*  Last Modified: Mon, 31 Oct 2022 (00:36:55)
*
*/
#include <iostream>
#include <set>
using namespace std;

const int N = 3005;

int n, m, k, s[N];
long long a, b, c, T;

long long ans = 0;
set <pair <int, pair <int, int>>> st;

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin >> n >> m >> k
		>> a >> b >> c >> T;

	for (int i = 0; i < m; i++)
		cin >> s[i];

	s[m] = n + 1;

	for (int i = 0; i < m; i++) {
		long long tmp = b * (s[i] - 1);
		if (tmp > T)
			break;

		long long x = (T - tmp) / a;
		x = min(x, 1LL * s[i + 1] - s[i] - 1);

		ans += x + 1;

		if (s[i] + x + 1 != s[i + 1]) {
			tmp += (x + 1) * c;

			if (tmp <= T) {
				long long y = (T - tmp) / a;
				y = min(y, s[i + 1] - s[i] - x - 2);

				st.insert({-(y + 1), {i, s[i] + x + y + 2}});
			}
		}
	}

	for (int it = 0; it < k - m && st.size(); it++) {
		int i = st.begin() -> second.first;
		long long x = st.begin() -> second.second;

		ans -= (st.begin() -> first);

		st.erase(st.begin());

		long long tmp = b * (s[i] - 1) + (x - s[i]) * c;

		if (tmp <= T && x != s[i + 1]) {
			long long y = (T - tmp) / a;
			y = min(y, 1LL * s[i + 1] - x - 1);

			st.insert({-(y + 1), {i, x + y + 1}});
		}
	}

	cout << ans - 1;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 324 KB Output is correct
5 Correct 1 ms 212 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 1 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 324 KB Output is correct
5 Correct 1 ms 212 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 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 1 ms 212 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 324 KB Output is correct
5 Correct 1 ms 212 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 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 1 ms 212 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 2 ms 340 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 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct