Submission #131441

# Submission time Handle Problem Language Result Execution time Memory
131441 2019-07-17T07:18:11 Z 구재현(#3186) Sparklers (JOI17_sparklers) C++14
50 / 100
116 ms 4532 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
using lint = long long;
using pi = pair<int, int>;

int n, k, L, a[MAXN], dp[MAXN][MAXN];
int t;

bool dfs(int l, int r){
	if(1ll * (r - l) * L < a[r] - a[l]) return 0;
	if(l == 1 && r == n) return 1;
	if(~dp[l][r]) return dp[l][r];
	bool ans = 0;
	if(l > 1) ans |= dfs(l - 1, r);
	if(r < n) ans |= dfs(l, r + 1);
	return dp[l][r] = ans;
}

bool trial(int s){
	memset(dp, -1, sizeof(dp));
	L = min(2ll * t * s, 2ll * a[n]);
	return dfs(k, k); 
}

int main(){
	scanf("%d %d %d",&n,&k,&t);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]);
	int s = 0, e = 1e9;
	while(s != e){
		int m = (s+e)/2;
		if(trial(m)) e = m;
		else s = m + 1;
	}
	cout << s << endl;
}

Compilation message

sparklers.cpp: In function 'bool dfs(int, int)':
sparklers.cpp:17:18: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  return dp[l][r] = ans;
         ~~~~~~~~~^~~~~
sparklers.cpp: In function 'int main()':
sparklers.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&n,&k,&t);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:28:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1; i<=n; i++) scanf("%d",&a[i]);
                          ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 11 ms 4204 KB Output is correct
2 Correct 11 ms 4244 KB Output is correct
3 Correct 11 ms 4216 KB Output is correct
4 Correct 12 ms 4344 KB Output is correct
5 Correct 11 ms 4220 KB Output is correct
6 Correct 11 ms 4344 KB Output is correct
7 Correct 11 ms 4344 KB Output is correct
8 Correct 11 ms 4344 KB Output is correct
9 Correct 11 ms 4344 KB Output is correct
10 Correct 11 ms 4216 KB Output is correct
11 Correct 11 ms 4344 KB Output is correct
12 Correct 11 ms 4344 KB Output is correct
13 Correct 12 ms 4344 KB Output is correct
14 Correct 11 ms 4344 KB Output is correct
15 Correct 11 ms 4216 KB Output is correct
16 Correct 12 ms 4216 KB Output is correct
17 Correct 12 ms 4344 KB Output is correct
18 Correct 11 ms 4216 KB Output is correct
19 Correct 12 ms 4216 KB Output is correct
20 Correct 12 ms 4216 KB Output is correct
21 Correct 11 ms 4216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 4204 KB Output is correct
2 Correct 11 ms 4244 KB Output is correct
3 Correct 11 ms 4216 KB Output is correct
4 Correct 12 ms 4344 KB Output is correct
5 Correct 11 ms 4220 KB Output is correct
6 Correct 11 ms 4344 KB Output is correct
7 Correct 11 ms 4344 KB Output is correct
8 Correct 11 ms 4344 KB Output is correct
9 Correct 11 ms 4344 KB Output is correct
10 Correct 11 ms 4216 KB Output is correct
11 Correct 11 ms 4344 KB Output is correct
12 Correct 11 ms 4344 KB Output is correct
13 Correct 12 ms 4344 KB Output is correct
14 Correct 11 ms 4344 KB Output is correct
15 Correct 11 ms 4216 KB Output is correct
16 Correct 12 ms 4216 KB Output is correct
17 Correct 12 ms 4344 KB Output is correct
18 Correct 11 ms 4216 KB Output is correct
19 Correct 12 ms 4216 KB Output is correct
20 Correct 12 ms 4216 KB Output is correct
21 Correct 11 ms 4216 KB Output is correct
22 Correct 49 ms 4472 KB Output is correct
23 Correct 36 ms 4344 KB Output is correct
24 Correct 22 ms 4344 KB Output is correct
25 Correct 17 ms 4344 KB Output is correct
26 Correct 49 ms 4344 KB Output is correct
27 Correct 55 ms 4344 KB Output is correct
28 Correct 81 ms 4344 KB Output is correct
29 Correct 81 ms 4444 KB Output is correct
30 Correct 66 ms 4344 KB Output is correct
31 Correct 76 ms 4472 KB Output is correct
32 Correct 78 ms 4344 KB Output is correct
33 Correct 107 ms 4344 KB Output is correct
34 Correct 50 ms 4344 KB Output is correct
35 Correct 83 ms 4344 KB Output is correct
36 Correct 37 ms 4344 KB Output is correct
37 Correct 34 ms 4532 KB Output is correct
38 Correct 80 ms 4376 KB Output is correct
39 Correct 26 ms 4344 KB Output is correct
40 Correct 116 ms 4460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 4204 KB Output is correct
2 Correct 11 ms 4244 KB Output is correct
3 Correct 11 ms 4216 KB Output is correct
4 Correct 12 ms 4344 KB Output is correct
5 Correct 11 ms 4220 KB Output is correct
6 Correct 11 ms 4344 KB Output is correct
7 Correct 11 ms 4344 KB Output is correct
8 Correct 11 ms 4344 KB Output is correct
9 Correct 11 ms 4344 KB Output is correct
10 Correct 11 ms 4216 KB Output is correct
11 Correct 11 ms 4344 KB Output is correct
12 Correct 11 ms 4344 KB Output is correct
13 Correct 12 ms 4344 KB Output is correct
14 Correct 11 ms 4344 KB Output is correct
15 Correct 11 ms 4216 KB Output is correct
16 Correct 12 ms 4216 KB Output is correct
17 Correct 12 ms 4344 KB Output is correct
18 Correct 11 ms 4216 KB Output is correct
19 Correct 12 ms 4216 KB Output is correct
20 Correct 12 ms 4216 KB Output is correct
21 Correct 11 ms 4216 KB Output is correct
22 Correct 49 ms 4472 KB Output is correct
23 Correct 36 ms 4344 KB Output is correct
24 Correct 22 ms 4344 KB Output is correct
25 Correct 17 ms 4344 KB Output is correct
26 Correct 49 ms 4344 KB Output is correct
27 Correct 55 ms 4344 KB Output is correct
28 Correct 81 ms 4344 KB Output is correct
29 Correct 81 ms 4444 KB Output is correct
30 Correct 66 ms 4344 KB Output is correct
31 Correct 76 ms 4472 KB Output is correct
32 Correct 78 ms 4344 KB Output is correct
33 Correct 107 ms 4344 KB Output is correct
34 Correct 50 ms 4344 KB Output is correct
35 Correct 83 ms 4344 KB Output is correct
36 Correct 37 ms 4344 KB Output is correct
37 Correct 34 ms 4532 KB Output is correct
38 Correct 80 ms 4376 KB Output is correct
39 Correct 26 ms 4344 KB Output is correct
40 Correct 116 ms 4460 KB Output is correct
41 Execution timed out 3 ms 632 KB Time limit exceeded (wall clock)
42 Halted 0 ms 0 KB -