結果

問題 No.1294 マウンテン数列
ユーザー 沙耶花沙耶花
提出日時 2020-06-01 21:19:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 679 bytes
コンパイル時間 2,068 ms
コンパイル使用メモリ 201,896 KB
実行使用メモリ 7,904 KB
最終ジャッジ日時 2023-09-18 01:37:19
合計ジャッジ時間 5,671 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,376 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000

int main(){
	
	int N;
	cin>>N;
	
	vector<int> A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	
	
	int ans = 0;
	do{
		vector<int> t(N-1);
		for(int i=0;i<N-1;i++){
			if(A[i]<A[i+1])t[i] = 1;
			else t[i]=-1;
		}
		
		bool f = true;
		
		for(int i=0;i<N-2;i++){
			if(t[i]==-1&&t[i+1]==1){
				f=false;
				break;
			}
		}
		
		if(f){
			int M = 0;
			for(int i=0;i<N-1;i++){
				M = max(M,abs(A[i]-A[i+1]));
			}
			ans = mod(ans + M);
		}	
	}
	while(next_permutation(A.begin(),A.end()));
	
	cout<<ans<<endl;
	
	return 0;
}
0