| 比赛 |
26暑假集训模拟赛2 |
评测结果 |
ATMEEEEEEEEEEEEEEEEE |
| 题目名称 |
OohMoo Milk |
最终得分 |
5 |
| 用户昵称 |
2_16鸡扒拌面 |
运行时间 |
4.179 s |
| 代码语言 |
C++ |
内存使用 |
27.54 MiB |
| 提交时间 |
2026-07-02 12:28:07 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int N,D,A,B;
ll m[10];
ll calc(vector<ll>& b){
ll res=0;
for(ll x:b)res=(res+(x%MOD)*(x%MOD))%MOD;
return res;
}
ll dfs(vector<ll> bottles,int day){
if(day==D)return calc(bottles);
int n=bottles.size();
ll best=0;
vector<int> choose(n,1);
for(int i=0;i<n-A;i++)choose[i]=0;
sort(choose.begin(),choose.end());
do{
vector<ll> after=bottles;
for(int i=0;i<n;i++)if(choose[i])after[i]++;
sort(after.begin(),after.end(),greater<ll>());
for(int i=0;i<B;i++)if(after[i]>0)after[i]--;
best=max(best,dfs(after,day+1));
}while(next_permutation(choose.begin(),choose.end()));
return best;
}
int main(){
freopen("Milk.in","r",stdin);
freopen("Milk.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N>>D;
cin>>A>>B;
for(int i=0;i<N;i++)cin>>m[i];
vector<ll> bottles(m,m+N);
cout<<dfs(bottles,0)<<"\n";
return 0;
cout<<0<<"\n";
return 0;
}