답안 #138515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
138515 2019-07-30T05:56:07 Z Retro3014 Sparklers (JOI17_sparklers) C++17
0 / 100
3 ms 376 KB
#include <bits/stdc++.h>

#define pb push_back
#define all(v) ((v).begin(), (v).end())
#define sortv(v) sort(all(v))
#define sz(v) ((int)(v).size())
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define umax(a, b) (a)=max((a), (b))
#define umin(a, b) (a)=min((a), (b))
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define rep(i,n) FOR(i,1,n)
#define rep0(i,n) FOR(i,0,(int)(n)-1)
#define FI first
#define SE second
#define INF 2000000000
#define INFLL 1000000000000000000LL


using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int N, K;
ll T;
vector<ll> v;

bool chk(ll x){
	if(x * T >= 1000000000LL){
		return true;
	}
	//cout<<x<<endl;
	pll now = {(ll)K, (ll)K};
	ll n = (ll)K;
	bool dir = false;
	while(1){
		//cout<<now.first<<" "<<now.second<<endl;
		if(now.first==0){
			if(now.second==N-1){
				return true;
			}
			dir = true;
		}else if(now.second==N-1){
			dir = false;
		}else{
			if((v[now.second+1] - v[now.first]) <= 2 * x * T * (now.second - now.first + 1)){
				dir = true;
			}else{
				dir = false;
			}
		}
		if(dir){
			if((v[now.second+1] - v[now.first])  > 2 * x * T * (now.second - now.first + 1)){
				return false;
			}
			n = now.second+1;
			now.second++;
		}else{
			if((v[now.second] - v[now.first - 1]) > 2 * x * T * (now.second - now.first + 1)){
				return false;
			}
			n = now.first - 1;
			now.first--;
		}
	}
}

int main(){
	scanf("%d%d%lld", &N, &K, &T);
	K--;
	for(int i=0; i<N; i++){
		ll x; scanf("%lld", &x);
		v.pb(x);
	}
	ll s = 0, e = INF, m;
	while(s<e){
		m = (s+e)/2;
		if(chk(m)){
			e = m;
		}else{
			s = m+1;
		}
	}
	printf("%lld", s);
	return 0;
}

Compilation message

sparklers.cpp: In function 'bool chk(ll)':
sparklers.cpp:34:5: warning: variable 'n' set but not used [-Wunused-but-set-variable]
  ll n = (ll)K;
     ^
sparklers.cpp: In function 'int main()':
sparklers.cpp:69:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%lld", &N, &K, &T);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:72:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   ll x; scanf("%lld", &x);
         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 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 252 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Incorrect 3 ms 376 KB Output isn't correct
11 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 252 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Incorrect 3 ms 376 KB Output isn't correct
11 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 252 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Incorrect 3 ms 376 KB Output isn't correct
11 Halted 0 ms 0 KB -