답안 #27837

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
27837 2017-07-14T07:43:15 Z 김동현(#1158) Sparklers (JOI17_sparklers) C++14
30 / 100
2000 ms 2800 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, k;
ll x[100010], t;

int can(ll v){
	for(int i = 0; i < (1 << (n - 1)); i++){
		if(__builtin_popcount(i) != k - 1) continue;
		int l = k - 1, r = k + 1, cnt = 0;
		ll s = x[k], e = x[k];
		int fl = 1;
		for(int j = 0; j < n - 1; j++){
			int c;
			cnt++;
			if((i >> j) & 1) c = l--;
			else c = r++;
			s -= v * t; e += v * t;
			ll ts = x[c] - v * cnt * t, te = x[c] + v * cnt * t;
			s = max(s, ts);
			e = min(e, te);
			if(s > e){ fl = 0; break; }
		}
		if(fl) return 1;
	}
	return 0;
}

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:31: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:32: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);
                                                  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2800 KB Output is correct
2 Correct 0 ms 2800 KB Output is correct
3 Correct 0 ms 2800 KB Output is correct
4 Correct 36 ms 2800 KB Output is correct
5 Correct 53 ms 2800 KB Output is correct
6 Correct 53 ms 2800 KB Output is correct
7 Correct 29 ms 2800 KB Output is correct
8 Correct 26 ms 2800 KB Output is correct
9 Correct 29 ms 2800 KB Output is correct
10 Correct 23 ms 2800 KB Output is correct
11 Correct 16 ms 2800 KB Output is correct
12 Correct 29 ms 2800 KB Output is correct
13 Correct 69 ms 2800 KB Output is correct
14 Correct 49 ms 2800 KB Output is correct
15 Correct 23 ms 2800 KB Output is correct
16 Correct 19 ms 2800 KB Output is correct
17 Correct 19 ms 2800 KB Output is correct
18 Correct 26 ms 2800 KB Output is correct
19 Correct 0 ms 2800 KB Output is correct
20 Correct 0 ms 2800 KB Output is correct
21 Correct 0 ms 2800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2800 KB Output is correct
2 Correct 0 ms 2800 KB Output is correct
3 Correct 0 ms 2800 KB Output is correct
4 Correct 36 ms 2800 KB Output is correct
5 Correct 53 ms 2800 KB Output is correct
6 Correct 53 ms 2800 KB Output is correct
7 Correct 29 ms 2800 KB Output is correct
8 Correct 26 ms 2800 KB Output is correct
9 Correct 29 ms 2800 KB Output is correct
10 Correct 23 ms 2800 KB Output is correct
11 Correct 16 ms 2800 KB Output is correct
12 Correct 29 ms 2800 KB Output is correct
13 Correct 69 ms 2800 KB Output is correct
14 Correct 49 ms 2800 KB Output is correct
15 Correct 23 ms 2800 KB Output is correct
16 Correct 19 ms 2800 KB Output is correct
17 Correct 19 ms 2800 KB Output is correct
18 Correct 26 ms 2800 KB Output is correct
19 Correct 0 ms 2800 KB Output is correct
20 Correct 0 ms 2800 KB Output is correct
21 Correct 0 ms 2800 KB Output is correct
22 Execution timed out 2000 ms 2800 KB Execution timed out
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2800 KB Output is correct
2 Correct 0 ms 2800 KB Output is correct
3 Correct 0 ms 2800 KB Output is correct
4 Correct 36 ms 2800 KB Output is correct
5 Correct 53 ms 2800 KB Output is correct
6 Correct 53 ms 2800 KB Output is correct
7 Correct 29 ms 2800 KB Output is correct
8 Correct 26 ms 2800 KB Output is correct
9 Correct 29 ms 2800 KB Output is correct
10 Correct 23 ms 2800 KB Output is correct
11 Correct 16 ms 2800 KB Output is correct
12 Correct 29 ms 2800 KB Output is correct
13 Correct 69 ms 2800 KB Output is correct
14 Correct 49 ms 2800 KB Output is correct
15 Correct 23 ms 2800 KB Output is correct
16 Correct 19 ms 2800 KB Output is correct
17 Correct 19 ms 2800 KB Output is correct
18 Correct 26 ms 2800 KB Output is correct
19 Correct 0 ms 2800 KB Output is correct
20 Correct 0 ms 2800 KB Output is correct
21 Correct 0 ms 2800 KB Output is correct
22 Execution timed out 2000 ms 2800 KB Execution timed out
23 Halted 0 ms 0 KB -