답안 #320559

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320559 2020-11-09T05:45:12 Z arnold518 Sparklers (JOI17_sparklers) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 100000;
const ll INF = 1e18;

int N, K;
ll T, A[MAXN+10], B[MAXN+10];

bool decide(ll X)
{
	X*=2;
	if(T*X>(ll)1e9) return true;
	for(int i=1; i<=N; i++) B[i]=A[i]-i*T*X;

	int l=K, r=K;
	ll lv=B[l], rv=B[r];
	while(!(l==0 && r==N+1))
	{
		int bl=l, br=r;
		lv=-INF;
		for(; l>=1 && B[l]>=rv; l--) lv=max(lv, B[l]);
		rv=INF;
		for(; r<=N && B[r]<=lv; r++) rv=min(rv, B[r]);
		if(l==bl && r==br) return false;
	}
	return true;
}

int main()
{
	scanf("%d%d%lld", &N, &K, &T);
	for(int i=1; i<=N; i++) scanf("%lld", &A[i]);

	ll lo=-1, hi=1e9+10;
	while(lo+1<hi)
	{
		ll mid=lo+hi>>1;
		if(decide(mid)) hi=mid;
		else lo=mid;
	}
	printf("%lld\n", hi);
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:42:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   42 |   ll mid=lo+hi>>1;
      |          ~~^~~
sparklers.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   36 |  scanf("%d%d%lld", &N, &K, &T);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:37:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   37 |  for(int i=1; i<=N; i++) scanf("%lld", &A[i]);
      |                          ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 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 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Incorrect 1 ms 364 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 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 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Incorrect 1 ms 364 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 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 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Incorrect 1 ms 364 KB Output isn't correct
13 Halted 0 ms 0 KB -