結果
問題 | No.2055 12x34... |
ユーザー | pengin_2000 |
提出日時 | 2022-08-21 13:08:22 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 137 ms / 2,000 ms |
コード長 | 1,749 bytes |
コンパイル時間 | 499 ms |
コンパイル使用メモリ | 31,872 KB |
実行使用メモリ | 12,800 KB |
最終ジャッジ日時 | 2024-04-18 12:49:24 |
合計ジャッジ時間 | 5,638 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 25 ms
5,376 KB |
testcase_03 | AC | 55 ms
7,936 KB |
testcase_04 | AC | 79 ms
10,368 KB |
testcase_05 | AC | 87 ms
11,008 KB |
testcase_06 | AC | 78 ms
10,112 KB |
testcase_07 | AC | 59 ms
8,192 KB |
testcase_08 | AC | 42 ms
6,400 KB |
testcase_09 | AC | 97 ms
12,032 KB |
testcase_10 | AC | 103 ms
12,708 KB |
testcase_11 | AC | 38 ms
6,144 KB |
testcase_12 | AC | 77 ms
7,552 KB |
testcase_13 | AC | 131 ms
11,008 KB |
testcase_14 | AC | 49 ms
5,760 KB |
testcase_15 | AC | 55 ms
5,760 KB |
testcase_16 | AC | 137 ms
11,520 KB |
testcase_17 | AC | 44 ms
6,400 KB |
testcase_18 | AC | 80 ms
10,240 KB |
testcase_19 | AC | 18 ms
5,376 KB |
testcase_20 | AC | 8 ms
5,376 KB |
testcase_21 | AC | 19 ms
5,376 KB |
testcase_22 | AC | 107 ms
12,800 KB |
testcase_23 | AC | 114 ms
12,800 KB |
testcase_24 | AC | 108 ms
12,800 KB |
testcase_25 | AC | 111 ms
12,672 KB |
testcase_26 | AC | 112 ms
12,716 KB |
testcase_27 | AC | 105 ms
12,800 KB |
testcase_28 | AC | 115 ms
12,784 KB |
testcase_29 | AC | 109 ms
12,760 KB |
testcase_30 | AC | 111 ms
12,800 KB |
testcase_31 | AC | 110 ms
12,672 KB |
testcase_32 | AC | 117 ms
12,768 KB |
testcase_33 | AC | 127 ms
12,800 KB |
testcase_34 | AC | 132 ms
12,800 KB |
testcase_35 | AC | 129 ms
12,784 KB |
testcase_36 | AC | 126 ms
12,784 KB |
testcase_37 | AC | 130 ms
12,800 KB |
testcase_38 | AC | 128 ms
12,800 KB |
testcase_39 | AC | 130 ms
12,800 KB |
testcase_40 | AC | 133 ms
12,800 KB |
testcase_41 | AC | 130 ms
12,800 KB |
testcase_42 | AC | 136 ms
12,800 KB |
ソースコード
#include<stdio.h> long long int h[400005], l; int comp_h(long long int a, long long int b) { if (h[a] > h[b]) return 1; else return -1; } void swap_h(long long int a, long long int b) { long long int f = h[a]; h[a] = h[b]; h[b] = f; return; } void push(long long int ne) { h[l] = ne; long long int p = l; l++; for (; p > 0; p = (p - 1) / 2) if (comp_h((p - 1) / 2, p) > 0) swap_h((p - 1) / 2, p); return; } long long int pop() { l--; swap_h(0, l); long long int p = 0; for (;;) { if (2 * p + 2 < l) { if (comp_h(2 * p + 1, 2 * p + 2) > 0) { if (comp_h(p, 2 * p + 2) > 0) swap_h(p, 2 * p + 2); p = 2 * p + 2; } else { if (comp_h(p, 2 * p + 1) > 0) swap_h(p, 2 * p + 1); p = 2 * p + 1; } } else if (2 * p + 1 < l) { if (comp_h(p, 2 * p + 1) > 0) swap_h(p, 2 * p + 1); p = 2 * p + 1; } else break; } return h[l]; } long long int n; long long int s[400005]; long long int fined_idx(long long int v) { long long int min, mid, max; min = -1; max = 2 * n; while (max - min > 1) { mid = (max + min) / 2; if (s[mid] < v) min = mid; else max = mid; } return max; } long long int a[200005]; long long int dp[400005]; int main() { scanf("%lld", &n); long long int i; for (i = 0; i < n; i++) scanf("%lld", &a[i]); long long int p = 998244353; l = 0; for (i = 0; i < n; i++) push(a[i]); for (i = 0; i < n; i++) push(a[i] - 1); for (i = 0; i < 2 * n; i++) s[i] = pop(); for (i = 0; i < 2 * n; i++) dp[i] = 0; long long int ans = 0; for (i = 0; i < n; i++) { ans += dp[fined_idx(a[i] - 1)]; ans %= p; dp[fined_idx(a[i])] += dp[fined_idx(a[i] - 1)] + 1; dp[fined_idx(a[i])] %= p; } printf("%lld\n", ans); return 0; }