[National Training Team] Aerobatics

Topic description:

QAQ…

Topic Analysis:

I made a table and found that as long as an action is determined for the first time, the last time, and the value of several times in the middle, it will not affect the value, then we will rank the value of each action. It's good that he has a big time interval...

Topic link:

Luogu 3918

AC code:

#include <cstdio>
#include <algorithm>
#include <cstring>
int val[1010],n,k;
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=k;i++) scanf("%d",&val[i]);
    std::sort(val+1,val+k+1);
    int l=1,r=n,ans=0;
    for(int i=k;i&&l<r;i--)
    {
        ans+=(r-l)*val[i];
        l++,r--;
    }
    printf("%d\n",ans);
    return 0;
} 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326660841&siteId=291194637