1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| #include<bits/stdc++.h> using namespace std; typedef long long ll;
int main(){ ios::sync_with_stdio(false);
ll n,m,worst; cin>>n>>m; priority_queue<ll> bars; for(int i=0;i<m;i++){ bars.push(0); } for(int i=0;i<n;i++){ ll total=bars.top(); bars.pop(); int ipt=0; cin>>ipt; total-=ipt; worst=max(-(total),worst); bars.push(total); } cout<<worst; return 0; }
|