This commit is contained in:
Zengtudor 2024-11-28 11:48:20 +08:00
parent 7ceea85559
commit 9e28b0004c

32
src/11/c4/P1190.cpp Normal file
View File

@ -0,0 +1,32 @@
#include <cstdint>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
using ll = int64_t;
ll n,m;
priority_queue<ll, vector<ll>,greater<>> list_pq;
int main(){
ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
cin>>n>>m;
for(ll i{1};i<=m;i++){
list_pq.emplace(0);
}
while(n--){
ll tmp;
cin>>tmp;
ll front{list_pq.top()};
list_pq.pop();
front+=tmp;
list_pq.emplace(front);
}
ll ans{};
while(list_pq.size()){
ans=list_pq.top();
list_pq.pop();
}
cout<<ans<<'\n';
}