Submission #559990

# Submission time Handle Problem Language Result Execution time Memory
559990 2022-05-11T02:27:31 Z amunduzbaev Sparklers (JOI17_sparklers) C++17
0 / 100
1 ms 320 KB
#include "bits/stdc++.h"
using namespace std;

#define ar array
#define int long long

const int inf = 1e9 + 5;

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n, k, t; cin>>n>>k>>t;
	
	vector<int> a(n), d(n);
	for(int i=0;i<n;i++) cin>>a[i], a[i] *= 2;
	for(int i=1;i<n;i++){
		d[i] = a[i] - a[i-1];
	}
	k--;
	
	auto check = [&](int s){
		vector<vector<int>> dp(n, vector<int>(n, -1));
		dp[k][k] = t * s;
		for(int len=0;len<n;len++){
			for(int i=0;i+len<n;i++){
				int j=i+len;
				if(j+1<n){
					int D = d[j+1] / 2;
					if(dp[i][j] >= D){
						dp[i][j+1] = max(dp[i][j+1], dp[i][j] - D + t * s);
					}
				} if(i){
					int D = d[i] / 2;
					if(dp[i][j] >= D){
						dp[i-1][j] = max(dp[i-1][j], dp[i][j] - D + t * s);
					}
				}
			}
		}
		
		return (~dp[0][n-1]);
	};
	
	int l = 1, r = 2 * inf;
	while(l < r){
		int m = (l + r) >> 1;
		if(check(m)) r = m;
		else l = m + 1;
	}
	
	cout<<(l+1) / 2<<"\n";
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 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 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 316 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Incorrect 1 ms 212 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 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 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 316 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Incorrect 1 ms 212 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 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 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 316 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Incorrect 1 ms 212 KB Output isn't correct
20 Halted 0 ms 0 KB -