답안 #27854

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
27854 2017-07-14T08:43:33 Z 시제연(#1161) Sparklers (JOI17_sparklers) C++
50 / 100
213 ms 20932 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
ll n, k, t, INF = 1LL<<60;
ll x[1100];
pll ran[1100][1100];

pll gyo(pll a, pll b) {
	ll s = max(a.first,b.first), e = min(a.second,b.second);
	if (s>e) return pll(INF,-INF);
	return pll(s,e);
}

pll hap(pll a, pll b) {
	return pll(min(a.first,b.first),max(a.second,b.second));
}

pll epn(pll a, ll k) {
	return pll(a.first-k,a.second+k);
}

bool ok(ll d) {
	int s, e, r;
	for (r=0;r<n;r++) {
		for (s=0;s<n-r;s++) {
			e = s+r;
			if (s>k||e<k) {
				ran[s][e] = pll(INF,-INF);
				continue;
			}
			if (s==e) {
				ran[s][s] = pll(x[k],x[k]);
				continue;
			}
			ran[s][e] = gyo(pll(0,1e9),hap(gyo(pll(x[s]-d*t*(e-s),x[s]+d*t*(e-s)),epn(ran[s+1][e],d*t)),
									   gyo(pll(x[e]-d*t*(e-s),x[e]+d*t*(e-s)),epn(ran[s][e-1],d*t))));
			//printf("%d, %d : %lld~%lld\n",s,e,ran[s][e].first,ran[s][e].second);
		}
	}
	return ran[0][n-1].first<=1e9+10;
}

int main() {
	int i;

	scanf("%lld%lld%lld",&n,&k,&t); k--;
	for (i=0;i<n;i++) scanf("%lld",&x[i]);
	ll s = 0, e = (1e9+10)/max(n-1,1LL);
	while(s<=e) {
		ll m = (s+e)>>1;
		if (ok(m)) e = m-1;
		else s = m+1;
	}
	printf("%lld\n",s);

    return 0;
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:49:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld",&n,&k,&t); k--;
                                ^
sparklers.cpp:50:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i=0;i<n;i++) scanf("%lld",&x[i]);
                                       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 20932 KB Output is correct
2 Correct 3 ms 20932 KB Output is correct
3 Correct 6 ms 20932 KB Output is correct
4 Correct 0 ms 20932 KB Output is correct
5 Correct 6 ms 20932 KB Output is correct
6 Correct 0 ms 20932 KB Output is correct
7 Correct 3 ms 20932 KB Output is correct
8 Correct 0 ms 20932 KB Output is correct
9 Correct 3 ms 20932 KB Output is correct
10 Correct 3 ms 20932 KB Output is correct
11 Correct 0 ms 20932 KB Output is correct
12 Correct 0 ms 20932 KB Output is correct
13 Correct 3 ms 20932 KB Output is correct
14 Correct 3 ms 20932 KB Output is correct
15 Correct 3 ms 20932 KB Output is correct
16 Correct 6 ms 20932 KB Output is correct
17 Correct 3 ms 20932 KB Output is correct
18 Correct 0 ms 20932 KB Output is correct
19 Correct 0 ms 20932 KB Output is correct
20 Correct 0 ms 20932 KB Output is correct
21 Correct 3 ms 20932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 20932 KB Output is correct
2 Correct 3 ms 20932 KB Output is correct
3 Correct 6 ms 20932 KB Output is correct
4 Correct 0 ms 20932 KB Output is correct
5 Correct 6 ms 20932 KB Output is correct
6 Correct 0 ms 20932 KB Output is correct
7 Correct 3 ms 20932 KB Output is correct
8 Correct 0 ms 20932 KB Output is correct
9 Correct 3 ms 20932 KB Output is correct
10 Correct 3 ms 20932 KB Output is correct
11 Correct 0 ms 20932 KB Output is correct
12 Correct 0 ms 20932 KB Output is correct
13 Correct 3 ms 20932 KB Output is correct
14 Correct 3 ms 20932 KB Output is correct
15 Correct 3 ms 20932 KB Output is correct
16 Correct 6 ms 20932 KB Output is correct
17 Correct 3 ms 20932 KB Output is correct
18 Correct 0 ms 20932 KB Output is correct
19 Correct 0 ms 20932 KB Output is correct
20 Correct 0 ms 20932 KB Output is correct
21 Correct 3 ms 20932 KB Output is correct
22 Correct 69 ms 20932 KB Output is correct
23 Correct 33 ms 20932 KB Output is correct
24 Correct 103 ms 20932 KB Output is correct
25 Correct 213 ms 20932 KB Output is correct
26 Correct 186 ms 20932 KB Output is correct
27 Correct 173 ms 20932 KB Output is correct
28 Correct 143 ms 20932 KB Output is correct
29 Correct 139 ms 20932 KB Output is correct
30 Correct 176 ms 20932 KB Output is correct
31 Correct 139 ms 20932 KB Output is correct
32 Correct 139 ms 20932 KB Output is correct
33 Correct 149 ms 20932 KB Output is correct
34 Correct 176 ms 20932 KB Output is correct
35 Correct 146 ms 20932 KB Output is correct
36 Correct 186 ms 20932 KB Output is correct
37 Correct 206 ms 20932 KB Output is correct
38 Correct 146 ms 20932 KB Output is correct
39 Correct 203 ms 20932 KB Output is correct
40 Correct 66 ms 20932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 20932 KB Output is correct
2 Correct 3 ms 20932 KB Output is correct
3 Correct 6 ms 20932 KB Output is correct
4 Correct 0 ms 20932 KB Output is correct
5 Correct 6 ms 20932 KB Output is correct
6 Correct 0 ms 20932 KB Output is correct
7 Correct 3 ms 20932 KB Output is correct
8 Correct 0 ms 20932 KB Output is correct
9 Correct 3 ms 20932 KB Output is correct
10 Correct 3 ms 20932 KB Output is correct
11 Correct 0 ms 20932 KB Output is correct
12 Correct 0 ms 20932 KB Output is correct
13 Correct 3 ms 20932 KB Output is correct
14 Correct 3 ms 20932 KB Output is correct
15 Correct 3 ms 20932 KB Output is correct
16 Correct 6 ms 20932 KB Output is correct
17 Correct 3 ms 20932 KB Output is correct
18 Correct 0 ms 20932 KB Output is correct
19 Correct 0 ms 20932 KB Output is correct
20 Correct 0 ms 20932 KB Output is correct
21 Correct 3 ms 20932 KB Output is correct
22 Correct 69 ms 20932 KB Output is correct
23 Correct 33 ms 20932 KB Output is correct
24 Correct 103 ms 20932 KB Output is correct
25 Correct 213 ms 20932 KB Output is correct
26 Correct 186 ms 20932 KB Output is correct
27 Correct 173 ms 20932 KB Output is correct
28 Correct 143 ms 20932 KB Output is correct
29 Correct 139 ms 20932 KB Output is correct
30 Correct 176 ms 20932 KB Output is correct
31 Correct 139 ms 20932 KB Output is correct
32 Correct 139 ms 20932 KB Output is correct
33 Correct 149 ms 20932 KB Output is correct
34 Correct 176 ms 20932 KB Output is correct
35 Correct 146 ms 20932 KB Output is correct
36 Correct 186 ms 20932 KB Output is correct
37 Correct 206 ms 20932 KB Output is correct
38 Correct 146 ms 20932 KB Output is correct
39 Correct 203 ms 20932 KB Output is correct
40 Correct 66 ms 20932 KB Output is correct
41 Runtime error 3 ms 20932 KB Execution killed because of forbidden syscall futex (202)
42 Halted 0 ms 0 KB -