Submission #208357

# Submission time Handle Problem Language Result Execution time Memory
208357 2020-03-11T01:26:06 Z bensonlzl Semiexpress (JOI17_semiexpress) C++14
48 / 100
1000 ms 21496 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){
		for (int i = 0; i <= K; ++i){
			for (int l = 0; l <= i; ++l){
				dp[j][i] = max(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 248 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 380 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 504 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 248 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 380 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 504 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 504 KB Output is correct
10 Correct 6 ms 504 KB Output is correct
11 Correct 6 ms 632 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 5 ms 504 KB Output is correct
14 Correct 5 ms 508 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 504 KB Output is correct
17 Correct 6 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 248 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 380 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 504 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 504 KB Output is correct
10 Correct 6 ms 504 KB Output is correct
11 Correct 6 ms 632 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 5 ms 504 KB Output is correct
14 Correct 5 ms 508 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 504 KB Output is correct
17 Correct 6 ms 504 KB Output is correct
18 Correct 5 ms 632 KB Output is correct
19 Correct 251 ms 17400 KB Output is correct
20 Execution timed out 1097 ms 21496 KB Time limit exceeded
21 Halted 0 ms 0 KB -