結果
| 問題 |
No.1733 Sum of Sorted Subarrays
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-05 22:06:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 584 ms / 3,000 ms |
| コード長 | 758 bytes |
| コンパイル時間 | 1,186 ms |
| コンパイル使用メモリ | 87,460 KB |
| 実行使用メモリ | 11,776 KB |
| 最終ジャッジ日時 | 2024-11-06 12:57:05 |
| 合計ジャッジ時間 | 10,560 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
コンパイルメッセージ
main.cpp:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
13 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<atcoder/modint>
#include<atcoder/lazysegtree>
using namespace std;
using mint=atcoder::modint998244353;
mint op(mint a,mint b){return a+b;}
mint e(){return mint(0);}
mint mp(mint f,mint x){return f*x;}
mint id(){return mint(1);}
int N;
main()
{
cin>>N;
vector<pair<int,int> >A(N);
for(int i=0;i<N;i++)
{
cin>>A[i].first;
A[i].second=i;
}
sort(A.begin(),A.end());
vector<mint>init(N+1,1);
atcoder::lazy_segtree<mint,op,e,mint,mp,mp,id>L(init),R(init);
mint ans=0;
for(int i=0;i<N;i++)
{
int id=A[i].second;
mint l=L.prod(0,id+1)/L.get(id+1);
mint r=R.prod(id+1,N+1)/R.get(id);
ans+=l*r*A[i].first;
L.apply(0,id+1,2);
R.apply(id+1,N+1,2);
}
cout<<ans.val()<<endl;
}