답안 #357547

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
357547 2021-01-24T05:38:07 Z YJU Sparklers (JOI17_sparklers) C++14
100 / 100
30 ms 2944 KB
#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ll N=1e6+5;
const ld pi=acos(-1);
const ll INF=(1LL<<60);
#define SQ(i) ((i)*(i))
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(_a) (ll)_a.size()
 
ll n,JOI,t,x[N],u[N];
 
bool ck(ll k){
	REP1(i,n)x[i]=u[i]-2*k*t*i;
	ll gl=1,gr=n;
	for(int i=1;i<=JOI;i++)gl=(x[i]>x[gl]?i:gl);
	for(int i=JOI;i<=n;i++)gr=(x[i]<x[gr]?i:gr);
	ll ql=JOI,qr=JOI;
	ll lv=x[ql],rv=x[qr];
	while(ql>=gl||qr<=gr){
		ll bl=ql,br=qr;
		for(;qr<=gr&&lv>=x[qr];qr++)rv=min(rv,x[qr]);
		for(;ql>=gl&&x[ql]>=rv;ql--)lv=max(lv,x[ql]);
		if(bl==ql&&br==qr)return 0;
	}
	ql=1;qr=n;
	lv=x[ql];rv=x[qr];
	while(ql<=gl||qr>=gr){
		ll bl=ql,br=qr;
		for(;qr>=gr&&lv>=x[qr];qr--)rv=min(rv,x[qr]);
		for(;ql<=gl&&x[ql]>=rv;ql++)lv=max(lv,x[ql]);
		if(bl==ql&&br==qr)return 0;
	}
	return 1;
}
 
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>JOI>>t;
	REP1(i,n)cin>>u[i];
	ll l=-1,r=1e9+10;
	while(r-l>1){
		ll mid=(l+r)>>1;
		if(ck(mid)){
			r=mid;
		}else{
			l=mid;
		}
	}
	cout<<r<<"\n";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 396 KB Output is correct
38 Correct 1 ms 384 KB Output is correct
39 Correct 1 ms 364 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 396 KB Output is correct
38 Correct 1 ms 384 KB Output is correct
39 Correct 1 ms 364 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 21 ms 2028 KB Output is correct
42 Correct 1 ms 364 KB Output is correct
43 Correct 6 ms 876 KB Output is correct
44 Correct 28 ms 2924 KB Output is correct
45 Correct 26 ms 2924 KB Output is correct
46 Correct 27 ms 2924 KB Output is correct
47 Correct 28 ms 2924 KB Output is correct
48 Correct 26 ms 2924 KB Output is correct
49 Correct 29 ms 2924 KB Output is correct
50 Correct 27 ms 2924 KB Output is correct
51 Correct 27 ms 2924 KB Output is correct
52 Correct 30 ms 2924 KB Output is correct
53 Correct 26 ms 2924 KB Output is correct
54 Correct 27 ms 2924 KB Output is correct
55 Correct 26 ms 2924 KB Output is correct
56 Correct 29 ms 2924 KB Output is correct
57 Correct 26 ms 2924 KB Output is correct
58 Correct 27 ms 2944 KB Output is correct
59 Correct 23 ms 2156 KB Output is correct
60 Correct 26 ms 2924 KB Output is correct
61 Correct 25 ms 2796 KB Output is correct
62 Correct 26 ms 2924 KB Output is correct
63 Correct 28 ms 2924 KB Output is correct
64 Correct 26 ms 2884 KB Output is correct
65 Correct 26 ms 2924 KB Output is correct
66 Correct 26 ms 2924 KB Output is correct
67 Correct 26 ms 2924 KB Output is correct
68 Correct 26 ms 2924 KB Output is correct
69 Correct 26 ms 2924 KB Output is correct