답안 #128623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
128623 2019-07-11T07:45:27 Z jangwonyoung Sparklers (JOI17_sparklers) C++14
0 / 100
2 ms 376 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
int n,k;
ll t;
ll x[100001];
pair<ll,int>st[100001];
bool got[100001];
bool solve(ll s){
	ll blood=s;
	int l=k,r=k;
	for(int i=1; i<n ;i++) got[i]=false;
	for(int i=1; i<n ;i++){
		got[st[i].se]=true;
		while(got[l-1]){
			l--;
			blood-=x[l+1]-x[l];
			if(blood<0) return false;
			blood+=s;
		}
		while(got[r]){
			blood-=x[r+1]-x[r];
			if(blood<0) return false;
			blood+=s;
			r++;
		}
	}
	return true;
}
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> k >> t;
	for(int i=1; i<=n ;i++){
		cin >> x[i];
	}
	for(int i=1; i<n ;i++){
		st[i]={x[i+1]-x[i],i};
	}
	sort(st+1,st+n);
	ll l=0,r=1e9/t+1;
	while(l!=r){
		ll mid=(l+r)/2;
		if(solve(mid*t*2)) r=mid;
		else l=mid+1;
	}
	cout << l << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -