제출 #1283248

#제출 시각아이디문제언어결과실행 시간메모리
1283248tullStove (JOI18_stove)C++20
0 / 100
2 ms572 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define bp '\n' signed main(){ #ifdef LOCAL freopen("input.txt", "r", stdin); #endif cin.tie(nullptr)->sync_with_stdio(false); int n,k,l=0,r=0,x,m,t,ans=1e18; cin>>n>>k; vector<int>a(n); for(auto&e:a){ cin>>e; r+=e; } while(l<r){ m=l+(r-l)/2; int st=a[0],sc=1,val=0; for(int i=1;i<n;++i){ if(a[i]-st+1>m){ val+=a[i-1]-st+1; st=a[i]; ++sc; } } val+=a.back()-st+1; if(sc>k){ l=m+1; }else{ r=m; ans=min(ans,val); } //cout<<"-> "<<m<<' '<<sc<<' '<<val<<bp; } cout<<ans; return 0; } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...