結果
| 問題 | No.1525 Meximum Sum |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-12-26 14:15:02 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 2,000 ms |
| コード長 | 861 bytes |
| 記録 | |
| コンパイル時間 | 1,604 ms |
| コンパイル使用メモリ | 162,040 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2025-12-26 14:15:06 |
| 合計ジャッジ時間 | 3,152 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn long long
#define gt getchar
inline int read()
{
int x = 0,f = 1;
char ch = gt();
while(!isdigit(ch))
{
if(ch == '-') f = 0;
ch = gt();
}
while(isdigit(ch))
{
x = (x<<3)+(x<<1)+(ch^'0');
ch = gt();
}
return f?x:-x;
}
constexpr int maxn = 2e5+10;
int a[maxn];
int pos[maxn];
signed main()
{
int n = read();
for(int i = 1;i<=n;++i)
{
a[i] = read();
pos[a[i]] = i;
}
int l = pos[0],r = pos[0],ans = 0;
for(int i = 1;i<=n;++i)
{
ans += l*(n-r+1);
if(i<n)
{
l = min(l,pos[i]);
r = max(r,pos[i]);
}
}
printf("%lld",ans);
return 0;
}
/*
3
0 2 1
10
9 6 8 5 1 0 3 2 4 7
15
12 9 4 6 5 2 0 1 7 13 10 14 8 11 3
*/
vjudge1