답안 #131501

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
131501 2019-07-17T08:22:14 Z 이온조(#3179) Sparklers (JOI17_sparklers) C++14
50 / 100
98 ms 4700 KB
#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9;
const long long linf = 1LL * 1e18;
long long X[100009], mx;
int N, K, T, s;

void show() {
	printf("K: %d\n", K);
	for(int i=1; i<=N; i++) printf("%lld ", X[i]);
	puts("");
}

bool D[1009][1009];

void go(int l, int r) {
	if(D[l][r] || X[l] + 1LL*(r-l)*T*s < X[r] - 1LL*(r-l)*T*s) return;
	D[l][r] = 1;
	if(1 < l) go(l-1, r);
	if(r < N) go(l, r+1);
}

bool solve() {
	// show();
	for(int i=1; i<=N; i++) for(int j=1; j<=N; j++) D[i][j] = 0;
	go(K, K);
	return D[1][N];
}

void rev() {
	K = N - K + 1;
	for(int i=0; i<=N+1; i++) X[i] = mx - X[i];
	reverse(X, X+N+2);
}

int main() {
	scanf("%d%d%d",&N,&K,&T);
	for(int i=1; i<=N; i++) scanf("%lld",&X[i]);
	if(X[1] == X[N]) return !printf("0");
	mx = X[N];

	int l = 1, r = INF;
	while(l <= r) {
		s = l+r >> 1;
		bool f1 = solve(); rev(); //printf("speed: %d, result: %d\n\n", s, f1);
		bool f2 = solve(); rev(); //printf("speed: %d, result: %d\n\n", s, f2);
		if(f1 || f2) r = s-1;
		else l = s+1;
	}
	printf("%d", r+1);
	return 0;
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:45:8: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   s = l+r >> 1;
       ~^~
sparklers.cpp:38: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:39: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("%lld",&X[i]);
                          ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 49 ms 1016 KB Output is correct
23 Correct 31 ms 888 KB Output is correct
24 Correct 27 ms 1272 KB Output is correct
25 Correct 37 ms 1400 KB Output is correct
26 Correct 66 ms 1460 KB Output is correct
27 Correct 69 ms 1400 KB Output is correct
28 Correct 91 ms 1436 KB Output is correct
29 Correct 88 ms 1408 KB Output is correct
30 Correct 71 ms 1400 KB Output is correct
31 Correct 82 ms 1400 KB Output is correct
32 Correct 91 ms 1400 KB Output is correct
33 Correct 98 ms 1400 KB Output is correct
34 Correct 65 ms 1400 KB Output is correct
35 Correct 97 ms 1528 KB Output is correct
36 Correct 53 ms 1400 KB Output is correct
37 Correct 51 ms 1400 KB Output is correct
38 Correct 89 ms 1400 KB Output is correct
39 Correct 47 ms 1400 KB Output is correct
40 Correct 2 ms 252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 49 ms 1016 KB Output is correct
23 Correct 31 ms 888 KB Output is correct
24 Correct 27 ms 1272 KB Output is correct
25 Correct 37 ms 1400 KB Output is correct
26 Correct 66 ms 1460 KB Output is correct
27 Correct 69 ms 1400 KB Output is correct
28 Correct 91 ms 1436 KB Output is correct
29 Correct 88 ms 1408 KB Output is correct
30 Correct 71 ms 1400 KB Output is correct
31 Correct 82 ms 1400 KB Output is correct
32 Correct 91 ms 1400 KB Output is correct
33 Correct 98 ms 1400 KB Output is correct
34 Correct 65 ms 1400 KB Output is correct
35 Correct 97 ms 1528 KB Output is correct
36 Correct 53 ms 1400 KB Output is correct
37 Correct 51 ms 1400 KB Output is correct
38 Correct 89 ms 1400 KB Output is correct
39 Correct 47 ms 1400 KB Output is correct
40 Correct 2 ms 252 KB Output is correct
41 Runtime error 74 ms 4700 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Halted 0 ms 0 KB -