結果
問題 | No.2659 Manga App |
ユーザー | てんぷら |
提出日時 | 2024-03-01 01:30:43 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,159 bytes |
コンパイル時間 | 5,467 ms |
コンパイル使用メモリ | 323,012 KB |
実行使用メモリ | 253,056 KB |
最終ジャッジ日時 | 2024-09-29 13:23:25 |
合計ジャッジ時間 | 13,475 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,820 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | AC | 2 ms
6,820 KB |
testcase_04 | AC | 2 ms
6,816 KB |
testcase_05 | AC | 2 ms
6,820 KB |
testcase_06 | AC | 2 ms
6,816 KB |
testcase_07 | AC | 2 ms
6,820 KB |
testcase_08 | AC | 2 ms
6,816 KB |
testcase_09 | AC | 2 ms
6,820 KB |
testcase_10 | AC | 2 ms
6,820 KB |
testcase_11 | AC | 2 ms
6,816 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | AC | 1,373 ms
253,056 KB |
testcase_33 | AC | 1,318 ms
253,056 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
ソースコード
#include <atcoder/all> #include <bits/stdc++.h> using ll = long long; using ull = unsigned long long; #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define REP(i, m, n) for(int i = (int)(m); i < (int)(n); i++) using namespace std; using namespace atcoder; using mint = modint998244353; const int inf = 1000000007; const ll longinf = 1ll << 60; namespace modint_util { vector<mint> fact, invfact, inv; void init(int n = 1 << 20) { fact.assign(n + 1, 0); invfact.assign(n + 1, 0); inv.assign(n + 1, 0); fact[0] = 1; rep(i, n) fact[i + 1] = fact[i] * (i + 1); invfact[n] = fact[n].inv(); rep(i, n) invfact[n - i - 1] = invfact[n - i] * (n - i); rep(i, n) inv[i + 1] = invfact[i + 1] * fact[i]; } vector<mint> power_list(int n, mint v) { vector<mint> a(n); a[0] = 1; rep(i, n - 1) a[i + 1] = a[i] * v; return a; } mint comb(int n, int k) { if(k < 0 || k > n || n < 0) { return 0; } return fact[n] * fact[n - k] * fact[k]; } }; // namespace modint_util namespace fp = modint_util; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; ll b, c, x; cin >> b >> c >> x; ll d = b + c; vector<ll> a(n - 1); rep(i, n - 1) cin >> a[i]; vector<map<ll, ll>> dps(n), dpe(n); map<ll, ll> last; dps[0][0] = 0; ll ans = longinf; rep(i, n - 1) { { int k = i; ll t = 0; while(k < n - 1) { t += a[k++]; if(t % d > b) { break; } } if(k == n - 1) { for(auto [ct, cx] : dps[i]) { ll ret = max(ct + t - (x - cx), 0ll); if(ret % d > b) { ret = (ret + d - 1) / d * d; } ans = min(ans, ret); } } else { ll s = (t + d - 1) / d * d; ll e = t / d * d; ll need = t - e; for(auto [ct, cx] : dps[i]) { if(dpe[k].count(ct + s)) { dps[k][ct + s] = min(dps[k][ct + s], cx); } else { dps[k][ct + s] = cx; } } for(auto [ct, cx] : dps[i]) { if(cx + need > x) { continue; } if(dpe[k].count(ct + e)) { dpe[k][ct + e] = min(dpe[k][ct + e], cx + need); } else { dpe[k][ct + e] = cx + need; } } } } { int k = i; ll t = b; while(k < n - 1) { t += a[k++]; if(t % d > b) { break; } } if(k == n - 1) { t -= b; for(auto [ct, cx] : dpe[i]) { ll ret = max(ct + t - (x - cx), 0ll); if(ret % d > b) { ret = (ret + d - 1) / d * d; } ans = min(ans, ret); } } else { ll s = (t + d - 1) / d * d; ll e = t / d * d; ll need = t - e; s -= b; e -= b; for(auto [ct, cx] : dpe[i]) { if(dpe[k].count(ct + s)) { dps[k][ct + s] = min(dps[k][ct + s], cx); } else { dps[k][ct + s] = cx; } } for(auto [ct, cx] : dpe[i]) { if(cx + need > x) { continue; } if(dpe[k].count(ct + e)) { dpe[k][ct + e] = min(dpe[k][ct + e], cx + need); } else { dpe[k][ct + e] = cx + need; } } } } } cout << ans << endl; return 0; }