結果
問題 | No.1331 Moving Penguin |
ユーザー | norikame |
提出日時 | 2021-01-08 22:55:45 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,774 bytes |
コンパイル時間 | 2,246 ms |
コンパイル使用メモリ | 212,284 KB |
実行使用メモリ | 672,000 KB |
最終ジャッジ日時 | 2024-04-28 04:30:59 |
合計ジャッジ時間 | 5,737 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 10 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 62 ms
15,340 KB |
testcase_05 | MLE | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; #define v(t) vector<t> #define p(t) pair<t, t> #define p2(t, s) pair<t, s> #define vp(t) v(p(t)) #define rep(i, n) for (int i=0,i##_len=((int)(n)); i<i##_len; ++i) #define rep2(i, a, n) for (int i=((int)(a)),i##_len=((int)(n)); i<=i##_len; ++i) #define repr(i, n) for (int i=((int)(n)-1); i>=0; --i) #define rep2r(i, a, n) for (int i=((int)(n)),i##_len=((int)(a)); i>=i##_len; --i) #define repi(itr, c) for (__typeof((c).begin()) itr=(c).begin(); itr!=(c).end(); ++itr) #define repir(itr, c) for (__typeof((c).rbegin()) itr=(c).rbegin(); itr!=(c).rend(); ++itr) #define sz(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define RSORT(x) sort(rall(x)); #define pb push_back #define eb emplace_back #define INF (1e9) #define LINF (1e18) #define PI (acos(-1)) #define EPS (1e-7) #define DEPS (1e-10) const ll mod = (ll)(1e9+7); int main(){ int n; cin >> n; v(int) a(n); rep(i, n) cin >> a[i]; v(ll) dp(n); dp[0] = 1; v(set<p2(int,ll)>) add(n); rep(i, n) { auto itr = add[i].begin(); while (itr!=add[i].end()) { dp[i] = (dp[i] + itr->second) % mod; if (i+itr->first > n-1) itr = add[i].erase(itr); else { add[i+itr->first].emplace(itr->first, itr->second); ++itr; } } if (i+1<n && a[i]!=1) dp[i+1] = (dp[i+1] + dp[i]) % mod; if (i+a[i] <= n-1) add[i+a[i]].emplace(a[i], dp[i]); } cout << dp[n-1] << endl; return 0; }