結果
| 問題 |
No.1687 What the Heck?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-24 22:09:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 639 bytes |
| コンパイル時間 | 1,113 ms |
| コンパイル使用メモリ | 105,168 KB |
| 最終ジャッジ日時 | 2025-01-24 17:20:36 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 WA * 1 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)
int main(){
ll n;
cin >> n;
ll ans = -1;
if (n == 1){
cout << 0 << endl;
return 0;
}
map<int,int> mp;
rep(i,n){
ll x;
cin >> x;
mp[int(x)] = i+1;
}
ll sum = n*(n+1)/2;
for (int i = n;i >= 1;i--){
ans = max(sum - 2*mp[i],ans);
sum -= mp[i];
}
cout << ans << endl;
return 0;
}