답안 #27829

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
27829 2017-07-14T07:32:11 Z 김동현(#1158) Sparklers (JOI17_sparklers) C++14
0 / 100
66 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 = 1, e = 1e9;
	for(int 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 33 ms 2800 KB Output is correct
5 Correct 49 ms 2800 KB Output is correct
6 Correct 53 ms 2800 KB Output is correct
7 Correct 26 ms 2800 KB Output is correct
8 Correct 26 ms 2800 KB Output is correct
9 Correct 26 ms 2800 KB Output is correct
10 Correct 16 ms 2800 KB Output is correct
11 Correct 9 ms 2800 KB Output is correct
12 Correct 43 ms 2800 KB Output is correct
13 Correct 66 ms 2800 KB Output is correct
14 Correct 43 ms 2800 KB Output is correct
15 Correct 26 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 19 ms 2800 KB Output is correct
19 Incorrect 0 ms 2800 KB Output isn't correct
20 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 33 ms 2800 KB Output is correct
5 Correct 49 ms 2800 KB Output is correct
6 Correct 53 ms 2800 KB Output is correct
7 Correct 26 ms 2800 KB Output is correct
8 Correct 26 ms 2800 KB Output is correct
9 Correct 26 ms 2800 KB Output is correct
10 Correct 16 ms 2800 KB Output is correct
11 Correct 9 ms 2800 KB Output is correct
12 Correct 43 ms 2800 KB Output is correct
13 Correct 66 ms 2800 KB Output is correct
14 Correct 43 ms 2800 KB Output is correct
15 Correct 26 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 19 ms 2800 KB Output is correct
19 Incorrect 0 ms 2800 KB Output isn't correct
20 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 33 ms 2800 KB Output is correct
5 Correct 49 ms 2800 KB Output is correct
6 Correct 53 ms 2800 KB Output is correct
7 Correct 26 ms 2800 KB Output is correct
8 Correct 26 ms 2800 KB Output is correct
9 Correct 26 ms 2800 KB Output is correct
10 Correct 16 ms 2800 KB Output is correct
11 Correct 9 ms 2800 KB Output is correct
12 Correct 43 ms 2800 KB Output is correct
13 Correct 66 ms 2800 KB Output is correct
14 Correct 43 ms 2800 KB Output is correct
15 Correct 26 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 19 ms 2800 KB Output is correct
19 Incorrect 0 ms 2800 KB Output isn't correct
20 Halted 0 ms 0 KB -