Submission #131498

# Submission time Handle Problem Language Result Execution time Memory
131498 2019-07-17T08:21:05 Z 이온조(#3179) Sparklers (JOI17_sparklers) C++14
0 / 100
2 ms 380 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);
	if(N == 1) return !printf("0");
	for(int i=1; i<=N; i++) scanf("%lld",&X[i]);
	X[0] = X[1]; X[N+1] = X[N];
	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:46: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:40: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]);
                          ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 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 380 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 376 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 Incorrect 2 ms 380 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 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 380 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 376 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 Incorrect 2 ms 380 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 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 380 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 376 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 Incorrect 2 ms 380 KB Output isn't correct
20 Halted 0 ms 0 KB -