Submission #428679

# Submission time Handle Problem Language Result Execution time Memory
428679 2021-06-15T13:47:44 Z errorgorn Sparklers (JOI17_sparklers) C++17
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'

#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound

#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,k,t;
ll arr[100005];

bool memo[1005];

bool can(ll i){
	memset(memo,false,sizeof(memo));
	
	memo[1]=true;
	
	rep(x,2,n+1){
		rep(y,1,x){
			//cout<<x<<" "<<y<<" "<<arr[x]-arr[y]<<endl;
			if (memo[y] && arr[x]-arr[y]>2*i*(x-y)) memo[x]=true;
		}
	}
	
	return !memo[n];
}

int main(){
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(false);
	
	cin>>n>>k>>t;
	
	rep(x,1,n+1) cin>>arr[x];
	
	ll lo=-1,hi=1e9,mi;
	while (hi-lo>1){
		mi=hi+lo>>1;
		
		if (can(mi)) hi=mi;
		else lo=mi;
	}
	
	cout<<(hi+t-1)/t<<endl;
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:54:8: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   54 |   mi=hi+lo>>1;
      |      ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -