結果
| 問題 |
No.1687 What the Heck?
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2021-09-24 23:03:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 2,000 ms |
| コード長 | 492 bytes |
| コンパイル時間 | 2,250 ms |
| コンパイル使用メモリ | 201,868 KB |
| 最終ジャッジ日時 | 2025-01-24 17:41:32 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin>>n;
vector<ll> P(n),S(n+1);
rep(i,n) cin>>P[i];
vector<pair<ll,ll>> A(n);
rep(i,n) A[i]={P[i],i+1};
sort(ALL(A));
rep(i,n) S[i+1]=S[i]+A[i].second;
ll ma=0;
for(int i=1;i<n;i++) ma=max(ma,S[i]-A[i].second);
cout<<ma<<endl;
return 0;
}
umezo