Submission #428605

# Submission time Handle Problem Language Result Execution time Memory
428605 2021-06-15T13:11:24 Z errorgorn Sparklers (JOI17_sparklers) C++17
50 / 100
70 ms 4092 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'

#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound

#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,k,t;
ll arr[100005];

bool memo[1005][1005];

bool can(ll i){
	rep(x,0,1005) rep(y,0,1005) memo[x][y]=false;
	
	memo[k][k]=true;
	
	rep(x,0,n){
		rep(y,1,n-x+1){
			int l=y,r=y+x;
			
			if (arr[r]-arr[l]>2*i*x) memo[l][r]=false;
			if (memo[l][r]) memo[l-1][r]=memo[l][r+1]=true;
		}
	}
	
	return memo[1][n];
}

int main(){
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(false);
	
	cin>>n>>k>>t;
	
	rep(x,1,n+1) cin>>arr[x];
	
	ll lo=-1,hi=1e9,mi;
	while (hi-lo>1){
		mi=hi+lo>>1;
		
		if (can(mi)) hi=mi;
		else lo=mi;
	}
	
	cout<<(hi+t-1)/t<<endl;
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:56:8: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   56 |   mi=hi+lo>>1;
      |      ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1220 KB Output is correct
2 Correct 2 ms 1208 KB Output is correct
3 Correct 3 ms 1220 KB Output is correct
4 Correct 2 ms 1228 KB Output is correct
5 Correct 2 ms 1228 KB Output is correct
6 Correct 2 ms 1228 KB Output is correct
7 Correct 2 ms 1228 KB Output is correct
8 Correct 2 ms 1228 KB Output is correct
9 Correct 2 ms 1228 KB Output is correct
10 Correct 2 ms 1228 KB Output is correct
11 Correct 2 ms 1216 KB Output is correct
12 Correct 2 ms 1228 KB Output is correct
13 Correct 2 ms 1216 KB Output is correct
14 Correct 2 ms 1228 KB Output is correct
15 Correct 3 ms 1228 KB Output is correct
16 Correct 2 ms 1228 KB Output is correct
17 Correct 3 ms 1228 KB Output is correct
18 Correct 2 ms 1228 KB Output is correct
19 Correct 3 ms 1228 KB Output is correct
20 Correct 2 ms 1228 KB Output is correct
21 Correct 2 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1220 KB Output is correct
2 Correct 2 ms 1208 KB Output is correct
3 Correct 3 ms 1220 KB Output is correct
4 Correct 2 ms 1228 KB Output is correct
5 Correct 2 ms 1228 KB Output is correct
6 Correct 2 ms 1228 KB Output is correct
7 Correct 2 ms 1228 KB Output is correct
8 Correct 2 ms 1228 KB Output is correct
9 Correct 2 ms 1228 KB Output is correct
10 Correct 2 ms 1228 KB Output is correct
11 Correct 2 ms 1216 KB Output is correct
12 Correct 2 ms 1228 KB Output is correct
13 Correct 2 ms 1216 KB Output is correct
14 Correct 2 ms 1228 KB Output is correct
15 Correct 3 ms 1228 KB Output is correct
16 Correct 2 ms 1228 KB Output is correct
17 Correct 3 ms 1228 KB Output is correct
18 Correct 2 ms 1228 KB Output is correct
19 Correct 3 ms 1228 KB Output is correct
20 Correct 2 ms 1228 KB Output is correct
21 Correct 2 ms 1228 KB Output is correct
22 Correct 28 ms 1224 KB Output is correct
23 Correct 16 ms 1228 KB Output is correct
24 Correct 24 ms 1228 KB Output is correct
25 Correct 48 ms 1228 KB Output is correct
26 Correct 55 ms 1308 KB Output is correct
27 Correct 49 ms 1228 KB Output is correct
28 Correct 60 ms 1228 KB Output is correct
29 Correct 56 ms 1228 KB Output is correct
30 Correct 47 ms 1304 KB Output is correct
31 Correct 45 ms 1228 KB Output is correct
32 Correct 58 ms 1228 KB Output is correct
33 Correct 47 ms 1228 KB Output is correct
34 Correct 54 ms 1228 KB Output is correct
35 Correct 48 ms 1228 KB Output is correct
36 Correct 51 ms 1228 KB Output is correct
37 Correct 40 ms 1224 KB Output is correct
38 Correct 46 ms 1304 KB Output is correct
39 Correct 70 ms 1324 KB Output is correct
40 Correct 45 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1220 KB Output is correct
2 Correct 2 ms 1208 KB Output is correct
3 Correct 3 ms 1220 KB Output is correct
4 Correct 2 ms 1228 KB Output is correct
5 Correct 2 ms 1228 KB Output is correct
6 Correct 2 ms 1228 KB Output is correct
7 Correct 2 ms 1228 KB Output is correct
8 Correct 2 ms 1228 KB Output is correct
9 Correct 2 ms 1228 KB Output is correct
10 Correct 2 ms 1228 KB Output is correct
11 Correct 2 ms 1216 KB Output is correct
12 Correct 2 ms 1228 KB Output is correct
13 Correct 2 ms 1216 KB Output is correct
14 Correct 2 ms 1228 KB Output is correct
15 Correct 3 ms 1228 KB Output is correct
16 Correct 2 ms 1228 KB Output is correct
17 Correct 3 ms 1228 KB Output is correct
18 Correct 2 ms 1228 KB Output is correct
19 Correct 3 ms 1228 KB Output is correct
20 Correct 2 ms 1228 KB Output is correct
21 Correct 2 ms 1228 KB Output is correct
22 Correct 28 ms 1224 KB Output is correct
23 Correct 16 ms 1228 KB Output is correct
24 Correct 24 ms 1228 KB Output is correct
25 Correct 48 ms 1228 KB Output is correct
26 Correct 55 ms 1308 KB Output is correct
27 Correct 49 ms 1228 KB Output is correct
28 Correct 60 ms 1228 KB Output is correct
29 Correct 56 ms 1228 KB Output is correct
30 Correct 47 ms 1304 KB Output is correct
31 Correct 45 ms 1228 KB Output is correct
32 Correct 58 ms 1228 KB Output is correct
33 Correct 47 ms 1228 KB Output is correct
34 Correct 54 ms 1228 KB Output is correct
35 Correct 48 ms 1228 KB Output is correct
36 Correct 51 ms 1228 KB Output is correct
37 Correct 40 ms 1224 KB Output is correct
38 Correct 46 ms 1304 KB Output is correct
39 Correct 70 ms 1324 KB Output is correct
40 Correct 45 ms 1228 KB Output is correct
41 Runtime error 13 ms 4092 KB Execution killed with signal 11
42 Halted 0 ms 0 KB -