https://i1.wp.com/eblogarithm.com/wp-content/uploads/2017/07/Codeforces-Round-415-Div-2-problem-C-Do-you-want-a-date-Solution-In-CC1.png?fit=640%2C360

Codeforces Round #415 (Div. 2), problem: (C) Do you want a date? Solution In C/C++

#include <bits/stdc++.h>
using namespace std; long long n,a[300007],r[300007],m=1e9+7,sum=0; int main(){ std::cin >> n;r[0] = 1; for(int i = 0;i<n;i++)cin>>a[i],r[i+1]=(r[i]*2)%m; sort(a,a+n); for(int i=0;i<n;i++) sum+=(a[i]*(r[i]-r[n-i-1]))%m,sum%=m; cout << sum%m; }

(Visited 6 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: