답안 #776093

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
776093 2023-07-07T09:55:01 Z TheOpChicken Semiexpress (JOI17_semiexpress) C++17
100 / 100
1 ms 468 KB
#include <iostream>
#include <set>
using namespace std;

const int maxN = 3e3 + 5;
long long sarr[maxN], unreachable[maxN];

set<pair<long long, long long> > s;

long long A, B, C, T;

int main(){
	int n, m, k;
	cin >> n >> m >> k;

	cin >> A >> B >> C >> T;

	sarr[0] = 0;
	for (int i = 1; i <= m; i++) cin >> sarr[i],  sarr[i]--;
	sarr[m+1] = n;

	int ans = 0;

	for (int i = 0; i <= m; i++){
		if (sarr[i] == sarr[i+1]) continue;
		long long cons = sarr[i] * B;
		unreachable[i] = (T-cons+A)/A;
		unreachable[i] = min(unreachable[i], sarr[i+1] - sarr[i]);
		unreachable[i] = max(unreachable[i], 0ll);

		ans += unreachable[i];
	}

	for (int i = 0; i <= m; i++){
		if (sarr[i] == sarr[i+1]) continue;
		long long cons = sarr[i]*B + unreachable[i]*C;
		long long next = (T-cons+A)/A + unreachable[i];
		next = min(next, sarr[i+1] - sarr[i]);
		next = max(next, unreachable[i]);


		s.insert(make_pair(next-unreachable[i], i));
		unreachable[i] = next;
	}


	int count = 0;
	while(count < k-m){
		pair<long long, long long> best = *s.rbegin(); s.erase(--s.end());
		ans += best.first;
			
		int i = best.second;
		long long cons = sarr[i]*B + unreachable[i]*C;
		long long next = (T-cons+A)/A + unreachable[i];

		next = min(next, sarr[i+1] - sarr[i]);
		next = max(next, unreachable[i]);

		s.insert(make_pair(next-unreachable[i], i));
		unreachable[i] = next;

		count++;
	}

	cout << ans-1 << endl;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 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 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 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 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 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 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 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 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 312 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 444 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 468 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 308 KB Output is correct
30 Correct 1 ms 308 KB Output is correct