結果

問題 No.2055 12x34...
ユーザー MagentorMagentor
提出日時 2022-08-21 20:53:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 274 ms / 2,000 ms
コード長 1,872 bytes
コンパイル時間 4,183 ms
コンパイル使用メモリ 231,360 KB
実行使用メモリ 19,968 KB
最終ジャッジ日時 2024-04-18 13:12:16
合計ジャッジ時間 9,025 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 11 ms
5,376 KB
testcase_03 AC 21 ms
5,376 KB
testcase_04 AC 30 ms
5,376 KB
testcase_05 AC 31 ms
5,376 KB
testcase_06 AC 28 ms
5,376 KB
testcase_07 AC 23 ms
5,376 KB
testcase_08 AC 17 ms
5,376 KB
testcase_09 AC 34 ms
5,376 KB
testcase_10 AC 37 ms
5,376 KB
testcase_11 AC 16 ms
5,376 KB
testcase_12 AC 143 ms
13,440 KB
testcase_13 AC 255 ms
19,328 KB
testcase_14 AC 88 ms
10,112 KB
testcase_15 AC 91 ms
10,240 KB
testcase_16 AC 274 ms
19,968 KB
testcase_17 AC 55 ms
5,376 KB
testcase_18 AC 105 ms
6,144 KB
testcase_19 AC 21 ms
5,376 KB
testcase_20 AC 9 ms
5,376 KB
testcase_21 AC 22 ms
5,376 KB
testcase_22 AC 137 ms
6,656 KB
testcase_23 AC 121 ms
9,728 KB
testcase_24 AC 113 ms
12,416 KB
testcase_25 AC 124 ms
10,624 KB
testcase_26 AC 116 ms
10,880 KB
testcase_27 AC 113 ms
12,928 KB
testcase_28 AC 116 ms
11,392 KB
testcase_29 AC 131 ms
12,416 KB
testcase_30 AC 121 ms
10,624 KB
testcase_31 AC 115 ms
10,624 KB
testcase_32 AC 114 ms
10,880 KB
testcase_33 AC 64 ms
5,376 KB
testcase_34 AC 64 ms
5,376 KB
testcase_35 AC 64 ms
5,376 KB
testcase_36 AC 64 ms
5,376 KB
testcase_37 AC 65 ms
5,376 KB
testcase_38 AC 65 ms
5,376 KB
testcase_39 AC 65 ms
5,376 KB
testcase_40 AC 64 ms
5,376 KB
testcase_41 AC 64 ms
5,376 KB
testcase_42 AC 64 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (long long)(n); i++)
#define REP(i, n) for (int i = 1; i < (long long)(n); i++)
typedef long long ll;
//#pragma GCC target("avx512f")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
#define updiv(N,X) (N + X - 1) / X
#define l(n) n.begin(),n.end()

#define YesNo(Q) Q==1?cout<<"Yes":cout<<"No"
using P = pair<int, int>;
using mint = modint998244353;
const int MOD = 998244353LL;
const ll INF = 999999999999LL;
vector<long long> fact, fact_inv, inv;
/*  init_nCk :二項係数のための前処理
    計算量:O(n)
*/
void init_nCk(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
    計算量:O(1)
*/
long long nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll POW(ll a,ll n){
  long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}


int main() {
	map<int, mint>mp;
	int n; cin >> n;
	mint ans = 0;
	rep(i, n) {
		int a; cin >> a;
		mint val = mp[a - 1];
		ans += val;
		mp[a] += val + 1;
	}
	cout << ans.val() << endl;
	return 0;
}
0