Contest Duration: ~ (local time) (150 minutes) Back to Home

Submission #4473963

Source Code Expand

Copy
```#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll factorial(ll n){
ll ret = 1;
FOR(i, 1, n+1){
ret *= i;
}
return ret;
}

int main(){
cin.tie(0);
ios::sync_with_stdio(false);

// input
ll N;
cin >> N;

vector<ll> A(N);
FOR(i, 0, N){
cin >> A.at(i);
}

double expectation = 0;

FOR(i, 0, N){
double p = 0;

FOR(j, 0, N){
ll n = abs(j-i)+1;
p += 1.0 / n;
}

expectation += A[i] * p;
}

ll ans = round(expectation * factorial(N));
ans %= mod;
p(ans);

return 0;
}```

#### Submission Info

Submission Time 2019-03-05 09:18:50+0900 B - Removing Blocks peroon C++14 (GCC 5.4.1) 0 1203 Byte TLE 2103 ms 1024 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
 AC × 3
 AC × 7 TLE × 12
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
sample-01.txt 1 ms 256 KB
sample-02.txt 1 ms 256 KB
sample-03.txt 1 ms 256 KB