結果

問題 No.2433 Min Increasing Sequence
ユーザー aradarad
提出日時 2023-08-19 16:18:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 1,452 bytes
コンパイル時間 4,075 ms
コンパイル使用メモリ 265,484 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2024-05-06 23:18:36
合計ジャッジ時間 6,767 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 81 ms
7,168 KB
testcase_05 AC 43 ms
5,376 KB
testcase_06 AC 65 ms
6,528 KB
testcase_07 AC 43 ms
5,376 KB
testcase_08 AC 72 ms
6,784 KB
testcase_09 AC 60 ms
6,016 KB
testcase_10 AC 27 ms
5,376 KB
testcase_11 AC 42 ms
5,504 KB
testcase_12 AC 26 ms
5,376 KB
testcase_13 AC 20 ms
5,376 KB
testcase_14 AC 53 ms
5,888 KB
testcase_15 AC 20 ms
5,376 KB
testcase_16 AC 26 ms
5,376 KB
testcase_17 AC 18 ms
5,376 KB
testcase_18 AC 75 ms
6,912 KB
testcase_19 AC 77 ms
6,912 KB
testcase_20 AC 6 ms
5,376 KB
testcase_21 AC 69 ms
6,656 KB
testcase_22 AC 78 ms
6,912 KB
testcase_23 AC 67 ms
6,400 KB
testcase_24 AC 77 ms
7,040 KB
testcase_25 AC 70 ms
6,656 KB
testcase_26 AC 55 ms
6,016 KB
testcase_27 AC 67 ms
6,528 KB
testcase_28 AC 61 ms
6,272 KB
testcase_29 AC 14 ms
5,376 KB
testcase_30 AC 12 ms
5,376 KB
testcase_31 AC 10 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using P = pair<ll,ll>;
using VP = vector<P>;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define out(x) cout << x << endl
#define dout(x) cout << fixed << setprecision(10) << x << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)(x.size())
#define re0 return 0
#define pcnt __builtin_popcountll
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr int inf = 1e9;
constexpr ll INF = 1e18;
//using mint = modint1000000007;
using mint = modint998244353;
int di[4] = {1,0,-1,0};
int dj[4] = {0,1,0,-1};

int main(){
    ll n;
    cin >> n;
    VL a(n);
    rep(i,n){
        cin >> a[i];
    }
    fenwick_tree<mint> dp(n);
    VL cmlmn(n);
    cmlmn[n-1] = a[n-1];
    for(int i = n-2;i >= 0;i--){
        cmlmn[i] = min(cmlmn[i+1],a[i]);
    }
    ll pi = -1;
    rep(i,n){
        if(cmlmn[i] != a[i]) continue;
        mint ad = dp.sum(0,i);
        ad *= i-pi;
        if(pi == -1) ad++;
        dp.add(i,ad);
        pi = i;
    }
    out(dp.sum(0,n).val());
}
0