比赛 26暑假集训模拟赛2 评测结果 AAAAAATTTTWWWWWWWWWW
题目名称 OohMoo Milk 最终得分 30
用户昵称 exil 运行时间 4.664 s
代码语言 C++ 内存使用 4.41 MiB
提交时间 2026-07-02 11:37:21
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define int long long
int xu[100005];
const int mod=1e9+7;
priority_queue<int,vector<int>,greater<int>>q;
signed main(){
    freopen("Milk.in","r",stdin);
    freopen("Milk.out","w",stdout);
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n,d;
    cin>>n>>d;
    int a,b;
    cin>>a>>b;
   
    int ans=0;
    for(int i = 1;i<=n;i++){
        cin>>xu[i];
    }
    if(d==1000000000){
        cout<<10;
        return 0;
    }
    sort(xu+1,xu+1+n);
    
    for(int i = n;i>n-a;i--){
        q.push(xu[i]);
    }
    for(int i  = 1;i<=d;i++){
        vector<int>v;
        for(int j = 1;j<=a-b;j++){
            int r=q.top();
            q.pop();
            
            r++;
            v.push_back(r);
        }
        for(int j = 1;j<=a-b;j++){
            q.push(v[j-1]);
        }
    }
    for(int i = 1;i<=n-a;i++){
        ans+=(xu[i]*xu[i])%mod;
        ans%=mod;
    }
    for(int i = 1;i<=a;i++){
        ans+=(q.top()*q.top())%mod;
        ans%=mod;
        q.pop();
    }
    cout<<ans;
    

    return 0;
}