結果

問題 No.2055 12x34...
ユーザー Nzt3Nzt3
提出日時 2022-09-25 20:02:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 306 ms / 2,000 ms
コード長 408 bytes
コンパイル時間 2,374 ms
コンパイル使用メモリ 209,368 KB
実行使用メモリ 20,188 KB
最終ジャッジ日時 2023-08-24 01:49:29
合計ジャッジ時間 8,502 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 7 ms
4,380 KB
testcase_03 AC 14 ms
4,376 KB
testcase_04 AC 18 ms
4,380 KB
testcase_05 AC 19 ms
4,380 KB
testcase_06 AC 18 ms
4,376 KB
testcase_07 AC 14 ms
4,380 KB
testcase_08 AC 11 ms
4,376 KB
testcase_09 AC 22 ms
4,376 KB
testcase_10 AC 23 ms
4,380 KB
testcase_11 AC 11 ms
4,380 KB
testcase_12 AC 155 ms
13,344 KB
testcase_13 AC 277 ms
19,636 KB
testcase_14 AC 95 ms
10,180 KB
testcase_15 AC 101 ms
10,232 KB
testcase_16 AC 306 ms
20,188 KB
testcase_17 AC 57 ms
4,760 KB
testcase_18 AC 125 ms
5,948 KB
testcase_19 AC 17 ms
4,376 KB
testcase_20 AC 6 ms
4,380 KB
testcase_21 AC 18 ms
4,376 KB
testcase_22 AC 175 ms
6,924 KB
testcase_23 AC 184 ms
9,868 KB
testcase_24 AC 104 ms
12,728 KB
testcase_25 AC 168 ms
10,604 KB
testcase_26 AC 144 ms
10,924 KB
testcase_27 AC 106 ms
13,144 KB
testcase_28 AC 137 ms
11,836 KB
testcase_29 AC 185 ms
12,736 KB
testcase_30 AC 163 ms
10,876 KB
testcase_31 AC 142 ms
10,652 KB
testcase_32 AC 142 ms
11,208 KB
testcase_33 AC 95 ms
4,376 KB
testcase_34 AC 96 ms
4,376 KB
testcase_35 AC 97 ms
4,376 KB
testcase_36 AC 97 ms
4,376 KB
testcase_37 AC 101 ms
4,380 KB
testcase_38 AC 97 ms
4,376 KB
testcase_39 AC 96 ms
4,376 KB
testcase_40 AC 98 ms
4,380 KB
testcase_41 AC 97 ms
4,376 KB
testcase_42 AC 100 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int mod=998244353;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  vector<int>A(N);
  for(int &i:A)cin>>i;
  map<int,unsigned>cnt;
  unsigned ans=0;
  for(int i=0;i<N;i++){
    ans=min(ans+cnt[A[i]-1],ans+cnt[A[i]-1]-mod);
    cnt[A[i]]=min(cnt[A[i]]+cnt[A[i]-1]+1,cnt[A[i]]+cnt[A[i]-1]+1-mod);
  }
  cout<<ans<<'\n';
}
0