Submission #540974

#TimeUsernameProblemLanguageResultExecution timeMemory
540974LittleOrangeStove (JOI18_stove)C++17
0 / 100
1 ms212 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; ll n,k; vector<ll> t; pair<ll,ll> check(ll cost){//return {price,count} vector<pair<ll,ll>> dp(n);//dp {price,count} dp[0] = {1,1}; for (int i = 1;i<n;i++){ if (t[i]-t[i-1]<cost){ dp[i] = {dp[i-1].first+t[i]-t[i-1],dp[i-1].second}; }else{ dp[i] = {dp[i-1].first+1,dp[i-1].second+1}; } } return dp[n-1]; } ll run(ll l, ll r){ if (l>=r) return check(l).first; ll mid = (l+r)>>1; if (check(mid).second<=k){ return run(l,mid); }else{ return run(mid+1,r); } } int main(){ ios::sync_with_stdio(0);cin.tie(); cin >> n >> k; t.resize(n); for (int i = 0;i<n;i++){ cin >> t[i]; } cout << run(0LL,1000000000000000000LL) << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...