結果
問題 |
No.1687 What the Heck?
|
ユーザー |
![]() |
提出日時 | 2021-10-02 09:26:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 621 bytes |
コンパイル時間 | 4,634 ms |
コンパイル使用メモリ | 232,240 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 03:22:15 |
合計ジャッジ時間 | 6,916 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 WA * 10 |
ソースコード
#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'; }