題目連結:d050. Q_4_8 先到先服務 (* – JMJudge
#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;
}