Submission #647969

# Submission time Handle Problem Language Result Execution time Memory
647969 2022-10-04T17:20:35 Z Koful123 Semiexpress (JOI17_semiexpress) C++17
100 / 100
52 ms 17088 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const int N = 3e3 + 3;
int dp[N][N];

void solve(){

	int n,m,k,a,b,c,t;
	cin >> n >> m >> k >> a >> b >> c >> t;

	vector<int> v(m+1);
	for(int i=1;i<=m;i++){
		cin >> v[i];
	}

	for(int i=1;i<m;i++){
		int time = t - (v[i]-1)*b,last = 0;
		vector<int> val(k-m+5,0);
		for(int q=0;q<=k-m;q++){
			if(time - last*c < 0 || last >= v[i+1]) break;
			int cur = (time - last*c) / a,len = v[i+1] - v[i];
			val[q] = min(len,last + cur + 1);
			last += cur+1;
		}
		for(int j=0;j<=k-m;j++){
			int l = 0,r = j;
			while(l < r){
				int mm = (l+r+1)/2;
				int cur = (mm ? val[mm-1] + dp[i-1][j-mm+1] : 0);
				if(val[mm] + dp[i-1][j-mm] > cur) l = mm;
				else r = mm-1;
			}
			dp[i][j] = val[l] + dp[i-1][j-l];
		}
	}

	int ans = 0;
	for(int i=1;i<m;i++){
		ans = max(ans,dp[i][k-m]);
	}

	cout << ans - ((v[m]-1)*b > t) << endl;
}

signed main(){

	ios::sync_with_stdio(0);
	cin.tie(0);

	int t = 1;
//	cin >> t;

	while(t--)
		solve();

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 22 ms 11396 KB Output is correct
20 Correct 50 ms 17088 KB Output is correct
21 Correct 3 ms 5588 KB Output is correct
22 Correct 7 ms 8092 KB Output is correct
23 Correct 52 ms 15484 KB Output is correct
24 Correct 3 ms 5332 KB Output is correct
25 Correct 2 ms 4308 KB Output is correct
26 Correct 4 ms 8404 KB Output is correct
27 Correct 5 ms 6372 KB Output is correct
28 Correct 3 ms 6612 KB Output is correct
29 Correct 15 ms 4564 KB Output is correct
30 Correct 9 ms 2132 KB Output is correct