結果
| 問題 |
No.1687 What the Heck?
|
| コンテスト | |
| ユーザー |
Drice27149
|
| 提出日時 | 2021-09-24 23:31:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 42 ms / 2,000 ms |
| コード長 | 453 bytes |
| コンパイル時間 | 368 ms |
| コンパイル使用メモリ | 45,252 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 11:35:24 |
| 合計ジャッジ時間 | 1,480 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#include <cstdio>
#include <algorithm>
#include <algorithm>
struct Element {
int u,v;
};
Element a[200005];
int main(){
int n;
scanf("%d",&n);
for(int i = 1; i <= n; i++){
scanf("%d",&a[i].u);
a[i].v = i;
}
std::sort(a+1, a+1+n, [](Element& u, Element& v){
return u.u < v.u;
});
long long ans = 0;
long long s = 0;
for(int i = 1; i <= n; i++){
s += a[i].v;
ans = std::max(ans, s-2ll*a[i].v);
}
printf("%lld\n",ans);
return 0;
}
Drice27149