Submission #2243962


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    vector<P> b(N, make_pair(1, 1));
    rep(i, N) {
        cin >> a[i];
    }
    rep(i, N) {
        for (int j=i-1; j>=0; --j) {
            if (a[j] > a[i]) b[i].first++;
            else break;
        }
        for (int j=i+1; j<N; ++j) {
            if (a[j] > a[i]) b[i].second++;
            else break;
        }
    }
    ll ans = 0;
    rep(i, N) {
        ans += a[i]*b[i].first*b[i].second;
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task B - Minimum Sum
User dsytk7
Language C++14 (GCC 5.4.1)
Score 0
Code Size 838 Byte
Status WA
Exec Time 2103 ms
Memory 2560 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 7
WA × 3
TLE × 3
Set Name Test Cases
Sample example0, example1, example2
All corner0, corner1, corner2, corner3, example0, example1, example2, maxrand0, maxrand1, maxrand2, rand0, rand1, rand2
Case Name Status Exec Time Memory
corner0 TLE 2103 ms 2560 KB
corner1 TLE 2103 ms 2560 KB
corner2 AC 1 ms 256 KB
corner3 TLE 2103 ms 2560 KB
example0 AC 1 ms 256 KB
example1 AC 1 ms 256 KB
example2 AC 1 ms 256 KB
maxrand0 WA 65 ms 2560 KB
maxrand1 WA 65 ms 2560 KB
maxrand2 WA 65 ms 2560 KB
rand0 AC 1 ms 256 KB
rand1 AC 1 ms 256 KB
rand2 AC 1 ms 256 KB