結果

問題 No.1687 What the Heck?
ユーザー yansi819yansi819
提出日時 2024-04-21 18:41:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 5,131 ms
コンパイル使用メモリ 260,284 KB
実行使用メモリ 17,408 KB
最終ジャッジ日時 2024-04-21 18:42:25
合計ジャッジ時間 7,741 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 52 ms
8,192 KB
testcase_08 AC 79 ms
10,368 KB
testcase_09 AC 51 ms
8,192 KB
testcase_10 AC 32 ms
6,528 KB
testcase_11 AC 36 ms
6,784 KB
testcase_12 AC 203 ms
17,280 KB
testcase_13 AC 185 ms
17,408 KB
testcase_14 AC 180 ms
17,280 KB
testcase_15 AC 170 ms
17,408 KB
testcase_16 AC 183 ms
17,152 KB
testcase_17 AC 12 ms
5,376 KB
testcase_18 AC 179 ms
17,280 KB
testcase_19 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;

int main() {
  ll N; cin >> N;
  vector<ll> a(N);
  for (auto &x: a) cin >> x;
  map<ll, ll> index;
  for (int i = 0; i < N; i++) {
    index[a[i]] = i + 1;
  }
  ll ans = 0;
  ll sum = N * (N + 1) / 2;
  for (int i = N; i >= 1; i--) {
    ans = max(ans, sum - index[i] * 2);
    sum -= index[i];
  }
  cout << ans << endl;
  return 0;
}
0