結果
問題 | No.1525 Meximum Sum |
ユーザー |
![]() |
提出日時 | 2024-10-20 12:15:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 462 bytes |
コンパイル時間 | 616 ms |
コンパイル使用メモリ | 64,136 KB |
実行使用メモリ | 10,268 KB |
最終ジャッジ日時 | 2024-10-20 12:15:30 |
合計ジャッジ時間 | 4,397 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 17 |
ソースコード
#include <iostream> using namespace std; const int N=1e6; int n; int a[N],p[N]; int ans; int main(){ //freopen("ffa2.in","r",stdin); cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; p[a[i]]=i; } int l=p[0],r=p[0]; for(int i=1;i<=n-1;i++){ int x=p[i]; if(x<l){ ans+=(l-x)*(n-r+1)*i; l=x; }else if(x>r){ ans+=(x-r)*l*i; r=x; } } cout<<ans+n; }