codeforces round #415 div2

Posted 123456

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeforces round #415 div2相关的知识,希望对你有一定的参考价值。

由于下午硬钢树套树和大力颓废就没补完

C:我傻逼比赛时没做出来。。。就是排个序然后算贡献

技术分享
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N  = 300010, mod = 1000000007;
int n;
ll ans, t = 1;
ll a[N], bin[N];
bool cp(int i, int j) { return i < j; }
int main()
{
    scanf("%d", &n);
    bin[0] = 1;
    for(int i = 1; i <= n; ++i) 
    {
        scanf("%lld", &a[i]);
        t = t * 2ll % mod;
        bin[i] = (bin[i - 1] + t) % mod;
    }
    sort(a + 1, a + n + 1, cp);
    for(int i = 2; i <= n; ++i) 
        ans = (ans + a[i] % mod * bin[i - 2] % mod) % mod;
    for(int i = n - 1; i; --i) 
        ans = ((ans - a[i] % mod * bin[n - i - 1] % mod) % mod + mod) % mod;
    printf("%lld\n", ans);         
    return 0;
}
View Code

 

以上是关于codeforces round #415 div2的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #415 (Div. 2)(A,暴力,B,贪心,排序)

Codeforces Round #415 (Div. 2)

(二分)Codeforces Round #415 (Div. 2) D-Glad to see you!

Codeforces Round #415 (Div. 2) C. Do you want a date?

Codeforces Round #415 (Div. 2) B. Summer sell-off(贪心+结构体排序)

Codeforces Round #705 (Div. 2)