結果

問題 No.1687 What the Heck?
ユーザー monnumonnu
提出日時 2021-10-02 09:26:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 621 bytes
コンパイル時間 4,033 ms
コンパイル使用メモリ 230,532 KB
実行使用メモリ 4,868 KB
最終ジャッジ日時 2023-09-27 09:14:34
合計ジャッジ時間 6,472 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 25 ms
4,376 KB
testcase_10 AC 17 ms
4,376 KB
testcase_11 AC 18 ms
4,376 KB
testcase_12 AC 74 ms
4,684 KB
testcase_13 AC 73 ms
4,856 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 20005
//#define MOD 1000000007
#define MOD 998244353
//#define INF 1000000000
#define INF 1000000000000000000

int main(){
  int N;
  cin>>N;
  vector<pair<int,int>> P(N);
  for(int i=0;i<N;i++){
    cin>>P[i].first;
    P[i].second=i;
  }
  sort(P.begin(),P.end(),greater<pair<int,int>>{});

  ll ans=0;
  ll sub=(ll)N*((ll)N+1)/2;
  for(int i=0;i<N;i++){
    ans=max<ll>(ans,sub-2*((ll)P[i].second+1));
    sub-=2*((ll)P[i].second+1);
  }
  cout<<ans<<'\n';
}
0