結果
| 問題 |
No.1687 What the Heck?
|
| コンテスト | |
| ユーザー |
monnu
|
| 提出日時 | 2021-10-02 09:29:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 85 ms / 2,000 ms |
| コード長 | 619 bytes |
| コンパイル時間 | 4,259 ms |
| コンパイル使用メモリ | 234,056 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 03:25:44 |
| 合計ジャッジ時間 | 5,954 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#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-=((ll)P[i].second+1);
}
cout<<ans<<'\n';
}
monnu