UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#212999#3846. Ddrdilyor609ms1184kbC++11762b2024-10-27 12:45:292024-10-27 13:04:00

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
void ts(){cout<<"IAKIOI\n";}
inline int read(){
	int n=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		n=n*10+ch-'0';
		ch=getchar();
	}
	return n*f;
}
int n;
int a[200005];
int dp[200005];
const int mod=998244353;
signed main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	dp[0]=1;
	for(int i=1;i<=n;i++){
		int c=a[i],h=0;
		for(int j=i;j>=1;j--){
			c=min(c,a[j]);
			if(a[j]>h){
				h=c;
				dp[i]+=dp[j-1],dp[i]%=mod;
			}
		}
	}
	cout<<dp[n]<<"\n";
	return 0;
}
//4
//3 2 4 1
//
//1 2 3 4
//2 3 4 1
//2 3 1 4
//3 1 2 4
//3 2 1 4
//3 2 4 1
//look at my code
//my code is amazing

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1164kb

input:

9
8 3 7 5 1 9 4 6 2

output:

119

result:

ok single line: '119'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1168kb

input:

96
76 80 31 17 29 3 90 91 78 14 77 72 55 37 25 68 86 8 13 81 22 84 51 89 85 48 42 73 33 74 41 46 75 ...

output:

346533342

result:

ok single line: '346533342'

Test #3:

score: 10
Accepted
time: 0ms
memory: 1164kb

input:

98
46 87 19 22 33 50 59 97 78 21 35 86 77 91 2 38 51 96 4 89 17 57 24 11 16 34 49 55 23 1 40 72 36 1...

output:

571340503

result:

ok single line: '571340503'

Test #4:

score: 10
Accepted
time: 3ms
memory: 1184kb

input:

970
728 101 949 443 727 288 701 430 316 696 512 243 770 830 34 878 835 332 737 181 643 340 1 434 930...

output:

796743423

result:

ok single line: '796743423'

Test #5:

score: 10
Accepted
time: 3ms
memory: 1180kb

input:

908
313 808 690 852 391 496 450 249 882 640 652 553 146 895 811 527 668 751 69 28 476 883 795 837 58...

output:

776563162

result:

ok single line: '776563162'

Test #6:

score: 10
Accepted
time: 3ms
memory: 1180kb

input:

921
38 95 562 752 468 872 694 738 200 624 711 917 862 822 587 769 806 746 111 561 775 55 93 753 814 ...

output:

502671405

result:

ok single line: '502671405'

Test #7:

score: 0
Time Limit Exceeded

input:

41028
40069 4862 34465 7845 23601 21317 30241 7624 27288 16148 34942 7075 11767 23226 7112 31560 135...

output:


result:


Test #8:

score: 0
Time Limit Exceeded

input:

48632
33309 1079 4839 2437 18205 419 33572 46703 38809 34638 44843 32634 11044 38115 42353 42793 100...

output:


result:


Test #9:

score: 0
Time Limit Exceeded

input:

171299
16588 124732 78456 29132 141990 59558 44485 27235 26213 111712 6386 44593 22397 80627 82247 6...

output:


result:


Test #10:

score: 0
Time Limit Exceeded

input:

196162
130344 62188 4747 83091 159990 96455 28701 30339 31430 28199 69935 182620 64274 6566 176986 4...

output:


result: