Submission #57740

# Submission time Handle Problem Language Result Execution time Memory
57740 2018-07-16T01:06:47 Z spencercompton Sparklers (JOI17_sparklers) C++17
50 / 100
79 ms 3944 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, k;
ll t;
bool v[1001][1001];
ll pos[1001];
// ll dp[2][1000][1000];
// ll pos[1000];
bool go(int l, int r){
	if((pos[r]-pos[l]>2LL*t*(ll)(r-l))){
		return false;
	}
	if(v[l][r]){
		return false;
	}
	if(l==0 && r==n-1){
		return true;
	}
	v[l][r] = true;
	if(l>0 && go(l-1,r)){
		return true;
	}
	if(r<n-1 && go(l,r+1)){
		return true;
	}
	return false;

}
int main(){
	ll tt;
	cin >> n >> k >> tt;
	for(int i = 0; i<n; i++){
		cin >> pos[i];
	}
	k--;
	ll low = 0LL;
	ll high = 1000000000LL;
	while(low<high){
		ll mid = (low+high)/2LL;
		t = mid*tt;
		for(int a = 0; a<1; a++){
			for(int b = 0; b<n; b++){
				for(int c = 0; c<n; c++){
					v[b][c] = false;
				}
			}
		}
		// cout << "! " << low << " " << high << " " << t << " " << endl;
		if(go(k,k)){
			// cout << "A " << endl;
			high = mid;
		}
		else{
			// cout << "B " << endl;
			low = mid+1;
		}
	}
	cout << low << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 532 KB Output is correct
5 Correct 2 ms 572 KB Output is correct
6 Correct 2 ms 632 KB Output is correct
7 Correct 3 ms 636 KB Output is correct
8 Correct 3 ms 640 KB Output is correct
9 Correct 3 ms 644 KB Output is correct
10 Correct 2 ms 648 KB Output is correct
11 Correct 2 ms 648 KB Output is correct
12 Correct 2 ms 716 KB Output is correct
13 Correct 2 ms 736 KB Output is correct
14 Correct 3 ms 740 KB Output is correct
15 Correct 2 ms 744 KB Output is correct
16 Correct 2 ms 796 KB Output is correct
17 Correct 2 ms 796 KB Output is correct
18 Correct 3 ms 932 KB Output is correct
19 Correct 2 ms 932 KB Output is correct
20 Correct 3 ms 932 KB Output is correct
21 Correct 4 ms 932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 532 KB Output is correct
5 Correct 2 ms 572 KB Output is correct
6 Correct 2 ms 632 KB Output is correct
7 Correct 3 ms 636 KB Output is correct
8 Correct 3 ms 640 KB Output is correct
9 Correct 3 ms 644 KB Output is correct
10 Correct 2 ms 648 KB Output is correct
11 Correct 2 ms 648 KB Output is correct
12 Correct 2 ms 716 KB Output is correct
13 Correct 2 ms 736 KB Output is correct
14 Correct 3 ms 740 KB Output is correct
15 Correct 2 ms 744 KB Output is correct
16 Correct 2 ms 796 KB Output is correct
17 Correct 2 ms 796 KB Output is correct
18 Correct 3 ms 932 KB Output is correct
19 Correct 2 ms 932 KB Output is correct
20 Correct 3 ms 932 KB Output is correct
21 Correct 4 ms 932 KB Output is correct
22 Correct 14 ms 1460 KB Output is correct
23 Correct 13 ms 1460 KB Output is correct
24 Correct 13 ms 1492 KB Output is correct
25 Correct 18 ms 1900 KB Output is correct
26 Correct 22 ms 1900 KB Output is correct
27 Correct 32 ms 1900 KB Output is correct
28 Correct 26 ms 1952 KB Output is correct
29 Correct 29 ms 1964 KB Output is correct
30 Correct 20 ms 1976 KB Output is correct
31 Correct 27 ms 1988 KB Output is correct
32 Correct 25 ms 2000 KB Output is correct
33 Correct 23 ms 2012 KB Output is correct
34 Correct 22 ms 2016 KB Output is correct
35 Correct 35 ms 2052 KB Output is correct
36 Correct 20 ms 2052 KB Output is correct
37 Correct 23 ms 2052 KB Output is correct
38 Correct 22 ms 2088 KB Output is correct
39 Correct 20 ms 2100 KB Output is correct
40 Correct 24 ms 2100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 532 KB Output is correct
5 Correct 2 ms 572 KB Output is correct
6 Correct 2 ms 632 KB Output is correct
7 Correct 3 ms 636 KB Output is correct
8 Correct 3 ms 640 KB Output is correct
9 Correct 3 ms 644 KB Output is correct
10 Correct 2 ms 648 KB Output is correct
11 Correct 2 ms 648 KB Output is correct
12 Correct 2 ms 716 KB Output is correct
13 Correct 2 ms 736 KB Output is correct
14 Correct 3 ms 740 KB Output is correct
15 Correct 2 ms 744 KB Output is correct
16 Correct 2 ms 796 KB Output is correct
17 Correct 2 ms 796 KB Output is correct
18 Correct 3 ms 932 KB Output is correct
19 Correct 2 ms 932 KB Output is correct
20 Correct 3 ms 932 KB Output is correct
21 Correct 4 ms 932 KB Output is correct
22 Correct 14 ms 1460 KB Output is correct
23 Correct 13 ms 1460 KB Output is correct
24 Correct 13 ms 1492 KB Output is correct
25 Correct 18 ms 1900 KB Output is correct
26 Correct 22 ms 1900 KB Output is correct
27 Correct 32 ms 1900 KB Output is correct
28 Correct 26 ms 1952 KB Output is correct
29 Correct 29 ms 1964 KB Output is correct
30 Correct 20 ms 1976 KB Output is correct
31 Correct 27 ms 1988 KB Output is correct
32 Correct 25 ms 2000 KB Output is correct
33 Correct 23 ms 2012 KB Output is correct
34 Correct 22 ms 2016 KB Output is correct
35 Correct 35 ms 2052 KB Output is correct
36 Correct 20 ms 2052 KB Output is correct
37 Correct 23 ms 2052 KB Output is correct
38 Correct 22 ms 2088 KB Output is correct
39 Correct 20 ms 2100 KB Output is correct
40 Correct 24 ms 2100 KB Output is correct
41 Runtime error 79 ms 3944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Halted 0 ms 0 KB -