Submission #27848

# Submission time Handle Problem Language Result Execution time Memory
27848 2017-07-14T08:12:27 Z 김동현(#1158) Sparklers (JOI17_sparklers) C++14
50 / 100
133 ms 18456 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll inf = 1e18;
int n, k;
ll x[100010], t, s[1001][1001], e[1001][1001];

void f(ll &ns, ll &ne, ll ts, ll te, ll cnt, ll cur, ll v){
	ts -= v * t; te += v * t;
	ll cs = x[cur] - v * cnt * t, ce = x[cur] + v * cnt * t;
	cs = max(cs, ts);
	ce = min(ce, te);
	if(cs <= ce){
		ns = cs;
		ne = ce;
	}
}

int can(ll v){
	for(int i = 1; i <= n; i++){
		fill(s[i] + 1, s[i] + n + 1, inf);
		fill(e[i] + 1, e[i] + n + 1, -inf);
	}
	s[k][k] = e[k][k] = x[k];
	for(int l = k; l >= 1; l--){
		for(int r = k + (l == k); r <= n; r++){
			f(s[l][r], e[l][r], s[l + 1][r], e[l + 1][r], r - l, l, v);
			f(s[l][r], e[l][r], s[l][r - 1], e[l][r - 1], r - l, r, v);
		}
	}
	return s[1][n] <= e[1][n];
}

int main(){
	scanf("%d%d%lld", &n, &k, &t);
	for(int i = 1; i <= n; i++) scanf("%lld", x + i);
	ll s = 0, e = 2 * ((ll(1e9) + t - 1) / t);
	for(ll m; s <= e; ){
		m = (s + e) / 2;
		if(can(m)) e = m - 1;
		else s = m + 1;
	}
	printf("%lld\n", s);
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:36:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%lld", &n, &k, &t);
                               ^
sparklers.cpp:37:50: 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("%lld", x + i);
                                                  ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 18456 KB Output is correct
2 Correct 0 ms 18456 KB Output is correct
3 Correct 0 ms 18456 KB Output is correct
4 Correct 0 ms 18456 KB Output is correct
5 Correct 0 ms 18456 KB Output is correct
6 Correct 0 ms 18456 KB Output is correct
7 Correct 0 ms 18456 KB Output is correct
8 Correct 0 ms 18456 KB Output is correct
9 Correct 0 ms 18456 KB Output is correct
10 Correct 0 ms 18456 KB Output is correct
11 Correct 0 ms 18456 KB Output is correct
12 Correct 0 ms 18456 KB Output is correct
13 Correct 0 ms 18456 KB Output is correct
14 Correct 0 ms 18456 KB Output is correct
15 Correct 0 ms 18456 KB Output is correct
16 Correct 0 ms 18456 KB Output is correct
17 Correct 0 ms 18456 KB Output is correct
18 Correct 0 ms 18456 KB Output is correct
19 Correct 0 ms 18456 KB Output is correct
20 Correct 0 ms 18456 KB Output is correct
21 Correct 0 ms 18456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 18456 KB Output is correct
2 Correct 0 ms 18456 KB Output is correct
3 Correct 0 ms 18456 KB Output is correct
4 Correct 0 ms 18456 KB Output is correct
5 Correct 0 ms 18456 KB Output is correct
6 Correct 0 ms 18456 KB Output is correct
7 Correct 0 ms 18456 KB Output is correct
8 Correct 0 ms 18456 KB Output is correct
9 Correct 0 ms 18456 KB Output is correct
10 Correct 0 ms 18456 KB Output is correct
11 Correct 0 ms 18456 KB Output is correct
12 Correct 0 ms 18456 KB Output is correct
13 Correct 0 ms 18456 KB Output is correct
14 Correct 0 ms 18456 KB Output is correct
15 Correct 0 ms 18456 KB Output is correct
16 Correct 0 ms 18456 KB Output is correct
17 Correct 0 ms 18456 KB Output is correct
18 Correct 0 ms 18456 KB Output is correct
19 Correct 0 ms 18456 KB Output is correct
20 Correct 0 ms 18456 KB Output is correct
21 Correct 0 ms 18456 KB Output is correct
22 Correct 59 ms 18456 KB Output is correct
23 Correct 23 ms 18456 KB Output is correct
24 Correct 39 ms 18456 KB Output is correct
25 Correct 76 ms 18456 KB Output is correct
26 Correct 113 ms 18456 KB Output is correct
27 Correct 113 ms 18456 KB Output is correct
28 Correct 116 ms 18456 KB Output is correct
29 Correct 123 ms 18456 KB Output is correct
30 Correct 123 ms 18456 KB Output is correct
31 Correct 133 ms 18456 KB Output is correct
32 Correct 123 ms 18456 KB Output is correct
33 Correct 129 ms 18456 KB Output is correct
34 Correct 106 ms 18456 KB Output is correct
35 Correct 126 ms 18456 KB Output is correct
36 Correct 96 ms 18456 KB Output is correct
37 Correct 89 ms 18456 KB Output is correct
38 Correct 106 ms 18456 KB Output is correct
39 Correct 86 ms 18456 KB Output is correct
40 Correct 113 ms 18456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 18456 KB Output is correct
2 Correct 0 ms 18456 KB Output is correct
3 Correct 0 ms 18456 KB Output is correct
4 Correct 0 ms 18456 KB Output is correct
5 Correct 0 ms 18456 KB Output is correct
6 Correct 0 ms 18456 KB Output is correct
7 Correct 0 ms 18456 KB Output is correct
8 Correct 0 ms 18456 KB Output is correct
9 Correct 0 ms 18456 KB Output is correct
10 Correct 0 ms 18456 KB Output is correct
11 Correct 0 ms 18456 KB Output is correct
12 Correct 0 ms 18456 KB Output is correct
13 Correct 0 ms 18456 KB Output is correct
14 Correct 0 ms 18456 KB Output is correct
15 Correct 0 ms 18456 KB Output is correct
16 Correct 0 ms 18456 KB Output is correct
17 Correct 0 ms 18456 KB Output is correct
18 Correct 0 ms 18456 KB Output is correct
19 Correct 0 ms 18456 KB Output is correct
20 Correct 0 ms 18456 KB Output is correct
21 Correct 0 ms 18456 KB Output is correct
22 Correct 59 ms 18456 KB Output is correct
23 Correct 23 ms 18456 KB Output is correct
24 Correct 39 ms 18456 KB Output is correct
25 Correct 76 ms 18456 KB Output is correct
26 Correct 113 ms 18456 KB Output is correct
27 Correct 113 ms 18456 KB Output is correct
28 Correct 116 ms 18456 KB Output is correct
29 Correct 123 ms 18456 KB Output is correct
30 Correct 123 ms 18456 KB Output is correct
31 Correct 133 ms 18456 KB Output is correct
32 Correct 123 ms 18456 KB Output is correct
33 Correct 129 ms 18456 KB Output is correct
34 Correct 106 ms 18456 KB Output is correct
35 Correct 126 ms 18456 KB Output is correct
36 Correct 96 ms 18456 KB Output is correct
37 Correct 89 ms 18456 KB Output is correct
38 Correct 106 ms 18456 KB Output is correct
39 Correct 86 ms 18456 KB Output is correct
40 Correct 113 ms 18456 KB Output is correct
41 Runtime error 86 ms 18456 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Halted 0 ms 0 KB -