結果

問題 No.2433 Min Increasing Sequence
ユーザー shobonvipshobonvip
提出日時 2023-08-11 19:07:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 1,768 bytes
コンパイル時間 4,725 ms
コンパイル使用メモリ 271,172 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-29 10:28:40
合計ジャッジ時間 8,350 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 115 ms
10,752 KB
testcase_05 AC 54 ms
6,940 KB
testcase_06 AC 88 ms
9,728 KB
testcase_07 AC 52 ms
7,168 KB
testcase_08 AC 94 ms
10,368 KB
testcase_09 AC 82 ms
9,088 KB
testcase_10 AC 39 ms
6,944 KB
testcase_11 AC 63 ms
7,424 KB
testcase_12 AC 35 ms
6,940 KB
testcase_13 AC 29 ms
6,940 KB
testcase_14 AC 74 ms
7,808 KB
testcase_15 AC 29 ms
6,940 KB
testcase_16 AC 36 ms
6,940 KB
testcase_17 AC 26 ms
6,944 KB
testcase_18 AC 106 ms
10,496 KB
testcase_19 AC 104 ms
10,496 KB
testcase_20 AC 7 ms
6,940 KB
testcase_21 AC 93 ms
9,856 KB
testcase_22 AC 103 ms
10,368 KB
testcase_23 AC 91 ms
9,728 KB
testcase_24 AC 112 ms
10,624 KB
testcase_25 AC 98 ms
10,112 KB
testcase_26 AC 74 ms
8,960 KB
testcase_27 AC 91 ms
9,856 KB
testcase_28 AC 84 ms
9,344 KB
testcase_29 AC 16 ms
6,944 KB
testcase_30 AC 17 ms
6,940 KB
testcase_31 AC 13 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

mint op(mint a, mint b){
	return a + b;
}

mint e(){
	return 0;
}

int main(){
	int n; cin >> n;
	vector<int> a(n);
	rep(i,0,n) cin >> a[i];
	vector<pair<int,int>> b(n);
	rep(i,0,n) b[i] = pair(a[i], i);
	sort(b.begin(), b.end());
	vector<int> c(n);
	rep(i,0,n){
		c[b[i].second] = i;
	}
	vector<int> leftmin(n+1);
	int piv = 0;
	int nowmx = 998244;
	rrep(i,0,n+1){
		leftmin[i] = piv;
		if(i-1 >= 0 && chmin(nowmx, c[i-1])) piv++;
	}

	/*
	rep(i,0,n+1){
		cout << leftmin[i] << " ";
	}
	cout << endl;
	*/

	vector<int> lb(n+1, 1e9);
	rep(i,0,n+1){
		chmin(lb[leftmin[i]], i);
	}
	
	segtree<mint,op,e> seg(n+1);
	seg.set(0, 1);
	rep(i,1,n+1){
		seg.set(i, seg.prod(0, lb[leftmin[i]])); 
	}

	cout << seg.get(n).val() << '\n';

}

0