結果
問題 |
No.1687 What the Heck?
|
ユーザー |
|
提出日時 | 2021-09-25 00:04:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 81 ms / 2,000 ms |
コード長 | 524 bytes |
コンパイル時間 | 1,560 ms |
コンパイル使用メモリ | 176,292 KB |
実行使用メモリ | 9,480 KB |
最終ジャッジ日時 | 2024-07-05 11:40:14 |
合計ジャッジ時間 | 2,991 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; int main(){ int N,M; cin>>N; vector<pair<int,ll>> p(N); for(int i=0;i<N;i++){ int P; cin>>P; p[i]={P,i+1}; } sort(p.begin(),p.end()); vector<ll> t(N); for(int i=0;i<N;i++){ t[i]=p[i].second; } ll ans=0; vector<ll> sum(N); partial_sum(t.begin(),t.end(),sum.begin()); for(int i=1;i<N;i++){ ans=max(ans,sum[i-1]-p[i].second); } cout<<ans<<endl; return 0; }