結果

問題 No.1525 Meximum Sum
ユーザー chocoruskchocorusk
提出日時 2021-05-31 20:30:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 1,015 bytes
コンパイル時間 3,832 ms
コンパイル使用メモリ 185,552 KB
実行使用メモリ 6,016 KB
最終ジャッジ日時 2024-04-26 08:17:12
合計ジャッジ時間 5,680 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 2 ms
5,248 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 41 ms
5,376 KB
testcase_09 AC 53 ms
5,632 KB
testcase_10 AC 17 ms
5,376 KB
testcase_11 AC 27 ms
5,376 KB
testcase_12 AC 54 ms
5,376 KB
testcase_13 AC 66 ms
5,888 KB
testcase_14 AC 67 ms
5,888 KB
testcase_15 AC 65 ms
5,888 KB
testcase_16 AC 64 ms
5,760 KB
testcase_17 AC 63 ms
5,760 KB
testcase_18 AC 64 ms
5,888 KB
testcase_19 AC 64 ms
5,760 KB
testcase_20 AC 64 ms
5,760 KB
testcase_21 AC 64 ms
5,888 KB
testcase_22 AC 64 ms
5,760 KB
testcase_23 AC 60 ms
5,888 KB
testcase_24 AC 63 ms
5,888 KB
testcase_25 AC 62 ms
6,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n; cin>>n;
    int ind[200020];
    for(int i=0; i<n; i++){
        int a; cin>>a;
        ind[a]=i;
    }
    ll x[200020];
    int l=n, r=0;
    for(int i=0; i<n; i++){
        l=min(l, ind[i]);
        r=max(r, ind[i]);
        x[i]=(ll)(l+1)*(n-r);
    }
    x[n]=0;
    ll ans=0;
    for(int i=0; i<n; i++){
        ans+=(ll)(i+1)*(x[i]-x[i+1]);
    }
    cout<<ans<<endl;
    return 0;
}
0