mirror of
https://gitcode.com/Zengtudor/alg2025.git
synced 2025-09-06 02:00:36 +00:00
update
This commit is contained in:
parent
27ecded092
commit
ac99a0f6fb
@ -1,28 +1,27 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cstdint>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <numeric>
|
#include <ostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using ll = int64_t;
|
using ll = int64_t;
|
||||||
|
|
||||||
#define pv(v)do{std::cout<<#v<<": "<<(v)<<"\n";}while(0)
|
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
std::iostream::sync_with_stdio(false);
|
std::iostream::sync_with_stdio(false);
|
||||||
std::cin.tie(nullptr);
|
std::cin.tie(nullptr);
|
||||||
|
|
||||||
ll n,k;
|
ll n,k;
|
||||||
std::cin>>n>>k;
|
std::cin>>n>>k;
|
||||||
std::vector<ll> v(n);
|
std::vector<ll> v(n+1),dp(n+1);
|
||||||
for(ll&i:v){
|
for(ll i=1;i<=n;i++){
|
||||||
std::cin>>i;
|
std::cin>>v[i];
|
||||||
}
|
}
|
||||||
std::sort(v.begin(),v.end());
|
for(ll i=1;i<=n;i++){
|
||||||
ll teams=n/k,last=n%k;
|
ll max=0;
|
||||||
ll teamssum = std::accumulate(v.rbegin(),v.rbegin()+teams,0);
|
for(ll len=1;len<=k&&len<=i;len++){
|
||||||
// pv(teams);
|
max=std::max(max,v[i-len+1]);
|
||||||
// pv(teamssum);
|
dp[i]=std::max(dp[i],max*len+dp[i-len]);
|
||||||
// pv(last);
|
}
|
||||||
std::cout<<(last * (*(v.rbegin()+teams)) + teamssum*k)<<"\n";
|
}
|
||||||
|
std::cout<<dp[n]<<std::endl;
|
||||||
|
_Exit(0);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user