結果

問題 No.2433 Min Increasing Sequence
ユーザー 👑 potato167potato167
提出日時 2023-08-15 22:39:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 639 bytes
コンパイル時間 2,395 ms
コンパイル使用メモリ 207,920 KB
実行使用メモリ 7,944 KB
最終ジャッジ日時 2024-05-03 09:04:45
合計ジャッジ時間 5,716 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 102 ms
7,944 KB
testcase_05 AC 42 ms
5,384 KB
testcase_06 AC 73 ms
7,136 KB
testcase_07 AC 45 ms
5,700 KB
testcase_08 AC 83 ms
7,532 KB
testcase_09 AC 62 ms
6,616 KB
testcase_10 AC 34 ms
5,376 KB
testcase_11 AC 53 ms
5,960 KB
testcase_12 AC 30 ms
5,376 KB
testcase_13 AC 25 ms
5,376 KB
testcase_14 AC 66 ms
6,204 KB
testcase_15 AC 27 ms
5,376 KB
testcase_16 AC 32 ms
5,376 KB
testcase_17 AC 24 ms
5,376 KB
testcase_18 AC 95 ms
7,640 KB
testcase_19 AC 98 ms
7,640 KB
testcase_20 AC 7 ms
5,376 KB
testcase_21 AC 87 ms
7,160 KB
testcase_22 AC 95 ms
7,620 KB
testcase_23 AC 85 ms
6,952 KB
testcase_24 AC 96 ms
7,692 KB
testcase_25 AC 90 ms
7,432 KB
testcase_26 AC 68 ms
6,316 KB
testcase_27 AC 85 ms
7,148 KB
testcase_28 AC 75 ms
6,756 KB
testcase_29 AC 17 ms
5,376 KB
testcase_30 AC 14 ms
5,376 KB
testcase_31 AC 12 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(p) p.begin(),p.end()
#define rep(i,a,b) for(int i=(int)a;i<(int)b;i++)
const int mod=998244353;

int main(){
	int N;
	cin>>N;
	vector<int> A(N),order(N),rev(N);
	rep(i,0,N) cin>>A[i],order[i]=i;
	sort(all(order),[&](int l,int r){
		if(A[l]==A[r]) return l<r;
		return A[l]<A[r];
	});
	vector<int> to(N);
	rep(i,0,N) rev[order[i]]=i;
	rev.push_back(N);
	int tmp=N;
	for(int i=N-1;i>=0;i--){
		if(rev[tmp]>rev[i]) tmp=i;
		to[i]=tmp+1;
	}
	vector<ll> dp(N+1);
	dp[0]=1;
	dp[1]=-1;
	rep(i,0,N) dp[i]%=mod,dp[to[i]]+=dp[i],dp[i+1]+=dp[i];
	cout<<dp[N]%mod<<"\n";
}
0