Submission #208358

# Submission time Handle Problem Language Result Execution time Memory
208358 2020-03-11T01:31:06 Z bensonlzl Semiexpress (JOI17_semiexpress) C++14
100 / 100
28 ms 22648 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll N, M, K, A, B, C, T, X;
vector<ll> segs;

int dp[3005][3005];
int cnt[3005][3005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> M >> K;
	cin >> A >> B >> C;
	cin >> T;
	for (int i = 1; i <= M; ++i){
		cin >> X;
		segs.push_back(X);
	}
	K -= M;
	for (int i = 1; i < segs.size(); ++i){
		ll l = segs[i-1], r = segs[i];
		ll cost = B*(l-1), curleft = segs[i-1] + (T - cost)/A;
		if (T - cost < 0) curleft = l-1;
		cnt[i][0] = min(curleft,r-1); 
		for (int j = 1; j <= K; ++j){
			if (curleft >= r-1){
				cnt[i][j] = r-1;
				continue;
			}
			ll nextstop = curleft+1;
			if ((T - C * (nextstop - segs[i-1]) - (B*(segs[i-1]-1))) >= 0) curleft = nextstop + (T - C * (nextstop - segs[i-1]) - (B*(segs[i-1]-1)))/A;
			cnt[i][j] = min(curleft,r-1); 
		}
	}
	for (int j = 1; j < segs.size(); ++j){
		int l = 0;
		for (int i = 0; i <= K; ++i){
			while (l < i && dp[j-1][i-l] + (int)(cnt[j][l] < segs[j-1] ? 0 : cnt[j][l] - segs[j-1] + 1) < dp[j-1][i-l-1] + (int)(cnt[j][l+1] < segs[j-1] ? 0 : cnt[j][l+1] - segs[j-1] + 1)){
				l++;
			}
			dp[j][i] = dp[j-1][i-l]+(int)(cnt[j][l] < segs[j-1] ? 0 : cnt[j][l] - segs[j-1] + 1);
		}
	}
	/*
	for (int i = 1; i < segs.size(); ++i){
		for (int j = 0; j <= K; ++j){
			cout << cnt[i][j] << ' ';
		}
		cout << '\n';
	}
	cout << "\n\n";
	for (int i = 1; i < segs.size(); ++i){
		for (int j = 0; j <= K; ++j){
			cout << dp[i][j] << ' ';
		}
		cout << '\n';
	}
	*/
	cout << dp[segs.size()-1][K] + (T >= (N-1) * B) - 1 << '\n';
}

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i < segs.size(); ++i){
                  ~~^~~~~~~~~~~~~
semiexpress.cpp:39:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int j = 1; j < segs.size(); ++j){
                  ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 1144 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 5 ms 632 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 1144 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 5 ms 632 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 508 KB Output is correct
11 Correct 5 ms 504 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 10 ms 632 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 504 KB Output is correct
17 Correct 5 ms 504 KB Output is correct
18 Correct 5 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 1144 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 5 ms 632 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 508 KB Output is correct
11 Correct 5 ms 504 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 10 ms 632 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 504 KB Output is correct
17 Correct 5 ms 504 KB Output is correct
18 Correct 5 ms 632 KB Output is correct
19 Correct 18 ms 17400 KB Output is correct
20 Correct 28 ms 22648 KB Output is correct
21 Correct 10 ms 10872 KB Output is correct
22 Correct 13 ms 14456 KB Output is correct
23 Correct 28 ms 22520 KB Output is correct
24 Correct 10 ms 10364 KB Output is correct
25 Correct 8 ms 8312 KB Output is correct
26 Correct 12 ms 16376 KB Output is correct
27 Correct 10 ms 12408 KB Output is correct
28 Correct 11 ms 12920 KB Output is correct
29 Correct 12 ms 6648 KB Output is correct
30 Correct 8 ms 2552 KB Output is correct