結果
| 問題 |
No.1687 What the Heck?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-21 18:41:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 268 ms / 2,000 ms |
| コード長 | 508 bytes |
| コンパイル時間 | 4,472 ms |
| コンパイル使用メモリ | 257,760 KB |
| 最終ジャッジ日時 | 2025-02-21 08:21:26 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#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;
}