結果
問題 | No.1709 Indistinguishable by MEX |
ユーザー |
![]() |
提出日時 | 2021-10-15 22:20:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 83 ms / 2,000 ms |
コード長 | 650 bytes |
コンパイル時間 | 3,842 ms |
コンパイル使用メモリ | 233,664 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 17:38:37 |
合計ジャッジ時間 | 6,250 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h>using namespace std;#include <atcoder/all>using namespace atcoder;using ll=long long;using Graph=vector<vector<int>>;#define INF 1000000000#define MOD 998244353#define MAX 200000int main(){int N;cin>>N;vector<pair<int,int>> P(N);for(int i=0;i<N;i++){cin>>P[i].first;P[i].second=i;}sort(P.begin(),P.end());int left=P[0].second;int right=P[0].second;ll ans=1;for(int i=1;i<N;i++){int k=P[i].second;if(left<=k&&k<=right){ans*=(ll)right-(ll)left+1-(ll)i;ans%=MOD;}else{left=min(left,k);right=max(right,k);}}cout<<ans<<'\n';}