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
Task B - Removing Blocks
User peroon
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1203 Byte
Status
Exec Time 2103 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
× 3
× 7
× 12
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt
All sample-01.txt, sample-02.txt, sample-03.txt, sample-01.txt, sample-02.txt, sample-03.txt, subtask01-01.txt, subtask01-02.txt, subtask01-03.txt, subtask01-04.txt, subtask01-05.txt, subtask01-06.txt, subtask01-07.txt, subtask01-08.txt, subtask01-09.txt, subtask01-10.txt, subtask01-11.txt, subtask01-12.txt, subtask01-13.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
subtask01-01.txt 1 ms 256 KB
subtask01-02.txt 2103 ms 896 KB
subtask01-03.txt 2103 ms 768 KB
subtask01-04.txt 2103 ms 896 KB
subtask01-05.txt 2103 ms 512 KB
subtask01-06.txt 2103 ms 640 KB
subtask01-07.txt 2103 ms 512 KB
subtask01-08.txt 2103 ms 1024 KB
subtask01-09.txt 2103 ms 1024 KB
subtask01-10.txt 2103 ms 1024 KB
subtask01-11.txt 2103 ms 1024 KB
subtask01-12.txt 2103 ms 1024 KB
subtask01-13.txt 2103 ms 1024 KB