Submission #27777

# Submission time Handle Problem Language Result Execution time Memory
27777 2017-07-14T05:25:39 Z 서규호(#1160) Sparklers (JOI17_sparklers) C++14
0 / 100
0 ms 2800 KB
#include <bits/stdc++.h>

#define lld long long
#define pii pair<int,int>
#define pll pair<lld,lld>
#define pb push_back
#define next nextt
#define left leftt
#define right rightt
#define Inf 1000000000
#define Linf 1000000000000000000LL
#define Mod 1000000007

using namespace std;

int N,M,ans; lld T;
lld a[100002];

bool can(lld X){
	X *= T; X %= Mod;
	int l,r,cnt;
	lld s,e;
	
	l = r = M; cnt = 1;
	s = e = a[M];
	while(r-l != N-1){
		if(l != 1 && max(s-X,a[l-1]-X*cnt) <= min(e+X,a[l-1]+X*cnt)){
			s = max(s-X,a[l-1]-X*cnt);
			e = min(e+X,a[l-1]+X*cnt);
			l--;
		}else if(r != N && max(s-X,a[r+1]-X*cnt) <= min(e+X,a[r+1]+X*cnt)){
			s = max(s-X,a[r+1]-X*cnt);
			e = min(e+X,a[r+1]+X*cnt);
			r++;
		}else return false;
		cnt++;
	}

	return true;
}

int main(){
	scanf("%d %d %lld",&N,&M,&T);
	for(int i=1; i<=N; i++){
		scanf("%lld",&a[i]);
	}
	int l,r;
	l = 0; r = a[N];
	while(l <= r){
		int m = (l+r)/2;
		if(can(m)){
			ans = m;
			r = m-1;
		}else l = m+1;
	}
	printf("%d\n",ans);

	return 0;
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:43:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %lld",&N,&M,&T);
                              ^
sparklers.cpp:45:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
                      ^
# Verdict Execution time Memory 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 0 ms 2800 KB Output is correct
5 Correct 0 ms 2800 KB Output is correct
6 Correct 0 ms 2800 KB Output is correct
7 Incorrect 0 ms 2800 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 0 ms 2800 KB Output is correct
5 Correct 0 ms 2800 KB Output is correct
6 Correct 0 ms 2800 KB Output is correct
7 Incorrect 0 ms 2800 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 0 ms 2800 KB Output is correct
5 Correct 0 ms 2800 KB Output is correct
6 Correct 0 ms 2800 KB Output is correct
7 Incorrect 0 ms 2800 KB Output isn't correct
8 Halted 0 ms 0 KB -