Submission #138457

# Submission time Handle Problem Language Result Execution time Memory
138457 2019-07-30T03:28:26 Z Retro3014 Sparklers (JOI17_sparklers) C++17
0 / 100
2 ms 256 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<int> v;

bool chk(ll x){
	if(x * T >= 1000000000LL){
		return true;
	}
	//cout<<x<<endl;
	pll now = {K, K};
	ll n = 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[n]) <= 2 * x * T * (now.second - now.first + 1)){
				dir = true;
			}else{
				dir = false;
			}
		}
		if(dir){
			if((v[now.second+1] - v[n])  > 2 * x * T * (now.second - now.first + 1)){
				return false;
			}
			n = now.second+1;
			now.second++;
		}else{
			if((v[n] - 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++){
		int x; scanf("%d", &x);
		v.pb(x);
	}
	ll s = 1, 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 '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:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int x; scanf("%d", &x);
          ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -