답안 #33313

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
33313 2017-10-23T11:39:34 Z cheater2k Semiexpress (JOI17_semiexpress) C++14
100 / 100
0 ms 2200 KB
#include <bits/stdc++.h>
using namespace std;

typedef pair<long long,long long> ii;
typedef pair<long long, ii> II;

const long long N = 3005;

long long n, m, k;
long long A, B, C, T;
long long s[N];
long long ans;
priority_queue <II> q;

void update(long long seg, long long posC) {
	if (posC >= s[seg + 1]) return;
	long long left = T - 1ll * s[seg] * B - 1ll * (posC - s[seg]) * C;
	if (left < 0) return;

	long long add = min((long long)(left / A) + 1, s[seg + 1] - posC);
	if (add > 0) q.push(II(add, ii(seg, posC + add))); 
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m >> k;
	cin >> A >> B >> C;
	cin >> T;
	for (long long i = 1; i <= m; ++i) cin >> s[i], --s[i];

	for (long long i = 2; i <= m; ++i) if (1ll * B * s[i] <= T) ++ans;

	for (long long i = 1; i < m; ++i) {
		long long left = T - 1ll * B * s[i];
		if (left < 0) continue;

		long long posC = s[i] + left / A + 1;
		ans += max(0LL, min(left / A, s[i + 1] - s[i] - 1));

		update(i, posC);
	}
	
	k -= m;
	while(k-- > 0 && !q.empty()) {
		II TOP = q.top(); q.pop();
		ans += TOP.first;
		long long seg = TOP.second.first, posC = TOP.second.second;

		update(seg, posC);
	}

	cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2200 KB Output is correct
2 Correct 0 ms 2200 KB Output is correct
3 Correct 0 ms 2200 KB Output is correct
4 Correct 0 ms 2200 KB Output is correct
5 Correct 0 ms 2200 KB Output is correct
6 Correct 0 ms 2200 KB Output is correct
7 Correct 0 ms 2200 KB Output is correct
8 Correct 0 ms 2200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2200 KB Output is correct
2 Correct 0 ms 2200 KB Output is correct
3 Correct 0 ms 2200 KB Output is correct
4 Correct 0 ms 2200 KB Output is correct
5 Correct 0 ms 2200 KB Output is correct
6 Correct 0 ms 2200 KB Output is correct
7 Correct 0 ms 2200 KB Output is correct
8 Correct 0 ms 2200 KB Output is correct
9 Correct 0 ms 2200 KB Output is correct
10 Correct 0 ms 2200 KB Output is correct
11 Correct 0 ms 2200 KB Output is correct
12 Correct 0 ms 2200 KB Output is correct
13 Correct 0 ms 2200 KB Output is correct
14 Correct 0 ms 2200 KB Output is correct
15 Correct 0 ms 2200 KB Output is correct
16 Correct 0 ms 2200 KB Output is correct
17 Correct 0 ms 2200 KB Output is correct
18 Correct 0 ms 2200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2200 KB Output is correct
2 Correct 0 ms 2200 KB Output is correct
3 Correct 0 ms 2200 KB Output is correct
4 Correct 0 ms 2200 KB Output is correct
5 Correct 0 ms 2200 KB Output is correct
6 Correct 0 ms 2200 KB Output is correct
7 Correct 0 ms 2200 KB Output is correct
8 Correct 0 ms 2200 KB Output is correct
9 Correct 0 ms 2200 KB Output is correct
10 Correct 0 ms 2200 KB Output is correct
11 Correct 0 ms 2200 KB Output is correct
12 Correct 0 ms 2200 KB Output is correct
13 Correct 0 ms 2200 KB Output is correct
14 Correct 0 ms 2200 KB Output is correct
15 Correct 0 ms 2200 KB Output is correct
16 Correct 0 ms 2200 KB Output is correct
17 Correct 0 ms 2200 KB Output is correct
18 Correct 0 ms 2200 KB Output is correct
19 Correct 0 ms 2200 KB Output is correct
20 Correct 0 ms 2200 KB Output is correct
21 Correct 0 ms 2200 KB Output is correct
22 Correct 0 ms 2200 KB Output is correct
23 Correct 0 ms 2200 KB Output is correct
24 Correct 0 ms 2200 KB Output is correct
25 Correct 0 ms 2200 KB Output is correct
26 Correct 0 ms 2200 KB Output is correct
27 Correct 0 ms 2200 KB Output is correct
28 Correct 0 ms 2200 KB Output is correct
29 Correct 0 ms 2200 KB Output is correct
30 Correct 0 ms 2200 KB Output is correct