提出 #34048577


ソースコード 拡げる

/** @file
 * @ingroup


 */
#include <bits/stdc++.h>
using namespace std;
template <typename T> inline void O(const T &x) { cout << x << '\n'; }
template <typename T, typename... W> inline void O(const T &x, const W &...b) {
  cout << x << ' ';
  O(b...);
}
template <typename T> inline void rd(T &x) { cin >> x; }
template <typename T, typename... W> inline void rd(T &x, W &...b) {
  cin >> x;
  rd(b...);
}
#ifndef MISAKA
#define err(...)
#else
#define err(...) fprintf(stderr, __VA_ARGS__)
#endif
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef long double dbl;
typedef pair<int, int> pii;
typedef uniform_int_distribution<int> r32;
typedef uniform_int_distribution<i64> r64;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define shuf(L, R) shuffle((L), (R), rng)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define FOR(i, j, k) for (int i = (j); i <= (k); ++i)
#define ROF(i, j, k) for (int i = (k); i >= (j); --i)
template <typename T> inline void ckmin(T &a, const T &b) { a = min(a, b); }
template <typename T> inline void ckmax(T &a, const T &b) { a = max(a, b); }
//#define IOFILE "filename"
//#define MULTI
const int N = 5005;
const int mod = 998244353;
int p[N];
int n;
int f[N];

inline void sol() {
  rd(n);
  FOR(i,1,n) rd(p[i]);
  f[0] = 1;
  FOR(i,1,n) {
    int l = i, r = i;
    while (l > 1 && p[l-1] < p[i]) --l;
    while (r < n && p[r+1] < p[i]) ++r;
    FOR(j,l,r) f[j] = (f[j] + f[j-1]) % mod;
  }
  O(f[n]);
}

int main() {
#ifndef MISAKA
#ifdef IOFILE
  freopen(IOFILE ".in", "r", stdin);
  freopen(IOFILE ".out", "w", stdout);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
#endif
#ifdef MULTI
  int T = 0;
  cin >> T;
  while (T--)
#endif
    sol();
  return 0;
}

提出情報

提出日時
問題 B - Adjacent Chmax
ユーザ misaka18931
言語 C++ (GCC 9.2.1)
得点 700
コード長 1872 Byte
結果 AC
実行時間 73 ms
メモリ 3488 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 700 / 700
結果
AC × 3
AC × 40
セット名 テストケース
Sample 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt
All 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt, 01-024.txt, 01-025.txt, 01-026.txt, 01-027.txt, 01-028.txt, 01-029.txt, 01-030.txt, 01-031.txt, 01-032.txt, 01-033.txt, 01-034.txt, 01-035.txt, 01-036.txt, 01-037.txt
ケース名 結果 実行時間 メモリ
00-sample-001.txt AC 9 ms 3416 KiB
00-sample-002.txt AC 2 ms 3400 KiB
00-sample-003.txt AC 2 ms 3444 KiB
01-001.txt AC 3 ms 3348 KiB
01-002.txt AC 5 ms 3436 KiB
01-003.txt AC 3 ms 3352 KiB
01-004.txt AC 3 ms 3416 KiB
01-005.txt AC 2 ms 3352 KiB
01-006.txt AC 2 ms 3400 KiB
01-007.txt AC 4 ms 3444 KiB
01-008.txt AC 4 ms 3432 KiB
01-009.txt AC 64 ms 3464 KiB
01-010.txt AC 66 ms 3372 KiB
01-011.txt AC 69 ms 3448 KiB
01-012.txt AC 68 ms 3452 KiB
01-013.txt AC 65 ms 3424 KiB
01-014.txt AC 71 ms 3488 KiB
01-015.txt AC 68 ms 3460 KiB
01-016.txt AC 69 ms 3444 KiB
01-017.txt AC 67 ms 3428 KiB
01-018.txt AC 66 ms 3420 KiB
01-019.txt AC 65 ms 3464 KiB
01-020.txt AC 66 ms 3420 KiB
01-021.txt AC 65 ms 3444 KiB
01-022.txt AC 64 ms 3452 KiB
01-023.txt AC 73 ms 3464 KiB
01-024.txt AC 64 ms 3464 KiB
01-025.txt AC 64 ms 3452 KiB
01-026.txt AC 69 ms 3448 KiB
01-027.txt AC 65 ms 3488 KiB
01-028.txt AC 59 ms 3444 KiB
01-029.txt AC 58 ms 3420 KiB
01-030.txt AC 63 ms 3428 KiB
01-031.txt AC 68 ms 3444 KiB
01-032.txt AC 65 ms 3416 KiB
01-033.txt AC 67 ms 3372 KiB
01-034.txt AC 59 ms 3464 KiB
01-035.txt AC 61 ms 3420 KiB
01-036.txt AC 25 ms 3452 KiB
01-037.txt AC 17 ms 3420 KiB