結果

問題 No.1687 What the Heck?
ユーザー mtrhmtrh
提出日時 2021-09-24 23:36:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 419 bytes
コンパイル時間 1,377 ms
コンパイル使用メモリ 172,628 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2024-07-05 11:36:05
合計ジャッジ時間 2,682 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 24 ms
5,376 KB
testcase_08 AC 34 ms
5,376 KB
testcase_09 AC 24 ms
5,376 KB
testcase_10 AC 17 ms
5,376 KB
testcase_11 AC 18 ms
5,376 KB
testcase_12 AC 72 ms
6,400 KB
testcase_13 AC 70 ms
6,400 KB
testcase_14 AC 70 ms
6,400 KB
testcase_15 AC 72 ms
6,400 KB
testcase_16 AC 71 ms
6,272 KB
testcase_17 AC 6 ms
5,376 KB
testcase_18 AC 71 ms
6,400 KB
testcase_19 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
    int N,M;
    cin>>N;
    vector<pair<int,ll>> p(N);
    for(int i=0;i<N;i++){
        int P;
        cin>>P;
        p[i]={P,i+1};
    }
    sort(p.begin(),p.end());
    ll ans=0;
    ll sum=p[0].second;
    for(int i=1;i<N;i++){
        ans=max(ans,sum-p[i].second);
        sum+=p[i].second;
    }
    cout<<ans<<endl;
    return 0;
}
0