Submission #75823317


Source Code Expand

#include <bits/stdc++.h>
#pragma warning(disable:4996)
#pragma comment(linker,"/STACK:336777216")
#pragma GCC optimize("03,unroll-loops")
#pragma GCC target("avx,avx2,fma")

using namespace std;
using ll = long long;
using vl = vector<ll>;
using ld = long double;
using pll = pair<ll,ll>;

ll POW(ll a,ll b,ll rem) {
    ll p=1;
    a %= rem;
    for (;b;b>>=1,a=(a*a)%rem) {
        if (b&1)p = (p*a)%rem;
    }
    return p;
}

tuple<ll,ll,ll> extended_gcd(ll a,ll b) {
    if (a==0) return {b,0,1};
    auto [g,x,y] = extended_gcd(b%a,a);
    return {g,y-(b/a)*x,x};
}
ll modinverse(ll a ,ll m) {
    return (get<1>(extended_gcd(a,m))%m+m)%m;
}

void pre() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void pre2() {
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}

void presolve() {

}

void solve() {
    ll N;
    cin>>N;
    vl v(N);
    vector<ld> M(N),Mhap(N),MMhap(N);
    for (auto &i:v)cin>>i;
    sort(v.begin(),v.end());

    for (int i=1;i<=N-1;i++) {
        M[i] = M[i-1]+(ld)1/(N-i);
    }
    for (int i=1;i<=N-1;i++) {
        MMhap[i] = MMhap[i-1]+(ld)(N-1)/(N-i);
    }

    ll hap=0;
    for (auto i:v)hap+=i;

    ld cnt=0;
    for (ll i=1;i<=N-1;i++) {
        Mhap[i] = Mhap[i-1] + M[i];
        cnt += Mhap[i];
    }

    ld ans=0;
    for (int i=0;i<N;i++) {
        ans += (ld)(N-i+1) * v[i] / 2;
    }

    if (N==1) {
        cout<<fixed;
        cout.precision(10);
        cout<<ans;
        return;
    }

    cout<<ans<<endl;
    for (int i=1;i<=N;i++) {
        ld tar = (ld)(N-1)*N/2;

        ans += (tar)*v[i-1]/N; // 뒤에 더하는거

        ld newavg = (ld)(hap-v[i-1])/(N-1);

        ld add=-(N-1)+MMhap[N-1];
        ans -= add/N*newavg;

        ld add2 = MMhap[N-1]/(N-1);
        ans -= add2/(N-1)*v[i-1];
    }

    cout<<fixed;
    cout.precision(10);
    cout<<ans;
}

int main() {
    pre();

    presolve();

    ll t=1;
    //cin>>t;
    while (t--) solve();
}

Submission Info

Submission Time
Task E - Opening Magical Box
User kuming19
Language C++23 (GCC 15.2.0)
Score 0
Code Size 2077 Byte
Status WA
Exec Time 12 ms
Memory 9100 KiB

Compile Error

./Main.cpp:2: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
    2 | #pragma warning(disable:4996)
./Main.cpp:3: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    3 | #pragma comment(linker,"/STACK:336777216")

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 1
WA × 1
AC × 3
WA × 47
Set Name Test Cases
Sample 00-sample-001.txt, 00-sample-002.txt
All 00-sample-001.txt, 00-sample-002.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt, 01-024.txt, 01-025.txt, 01-026.txt, 01-027.txt, 01-028.txt, 01-029.txt, 01-030.txt, 01-031.txt, 01-032.txt, 01-033.txt, 01-034.txt, 01-035.txt, 01-036.txt, 01-037.txt, 01-038.txt, 01-039.txt, 01-040.txt, 01-041.txt, 01-042.txt, 01-043.txt, 01-044.txt, 01-045.txt, 01-046.txt, 01-047.txt, 01-048.txt
Case Name Status Exec Time Memory
00-sample-001.txt AC 1 ms 3840 KiB
00-sample-002.txt WA 1 ms 3828 KiB
01-001.txt WA 6 ms 9048 KiB
01-002.txt WA 7 ms 8988 KiB
01-003.txt WA 11 ms 8912 KiB
01-004.txt WA 12 ms 9048 KiB
01-005.txt WA 12 ms 8988 KiB
01-006.txt WA 12 ms 9048 KiB
01-007.txt WA 12 ms 8980 KiB
01-008.txt WA 12 ms 9004 KiB
01-009.txt WA 12 ms 8928 KiB
01-010.txt WA 12 ms 9024 KiB
01-011.txt WA 12 ms 9044 KiB
01-012.txt WA 12 ms 8912 KiB
01-013.txt WA 12 ms 8912 KiB
01-014.txt WA 12 ms 8928 KiB
01-015.txt WA 12 ms 9024 KiB
01-016.txt WA 12 ms 9052 KiB
01-017.txt WA 12 ms 8984 KiB
01-018.txt WA 12 ms 9048 KiB
01-019.txt WA 12 ms 8984 KiB
01-020.txt WA 11 ms 8924 KiB
01-021.txt WA 12 ms 8964 KiB
01-022.txt WA 12 ms 9052 KiB
01-023.txt WA 1 ms 3676 KiB
01-024.txt AC 1 ms 3812 KiB
01-025.txt AC 1 ms 3840 KiB
01-026.txt WA 1 ms 3732 KiB
01-027.txt WA 1 ms 3768 KiB
01-028.txt WA 1 ms 3836 KiB
01-029.txt WA 1 ms 3676 KiB
01-030.txt WA 1 ms 3676 KiB
01-031.txt WA 1 ms 3748 KiB
01-032.txt WA 1 ms 3812 KiB
01-033.txt WA 1 ms 3700 KiB
01-034.txt WA 1 ms 3676 KiB
01-035.txt WA 1 ms 3664 KiB
01-036.txt WA 1 ms 3732 KiB
01-037.txt WA 7 ms 8912 KiB
01-038.txt WA 7 ms 9024 KiB
01-039.txt WA 7 ms 9100 KiB
01-040.txt WA 7 ms 9100 KiB
01-041.txt WA 7 ms 9024 KiB
01-042.txt WA 6 ms 8964 KiB
01-043.txt WA 6 ms 9100 KiB
01-044.txt WA 7 ms 9024 KiB
01-045.txt WA 7 ms 8928 KiB
01-046.txt WA 11 ms 9052 KiB
01-047.txt WA 1 ms 3968 KiB
01-048.txt WA 1 ms 3664 KiB