結果
問題 | No.2693 Sword |
ユーザー | nines |
提出日時 | 2024-03-22 22:30:26 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 9,057 bytes |
コンパイル時間 | 3,158 ms |
コンパイル使用メモリ | 259,572 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-09-30 11:59:31 |
合計ジャッジ時間 | 4,159 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 2 ms
6,820 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | AC | 2 ms
6,816 KB |
testcase_04 | AC | 2 ms
6,816 KB |
testcase_05 | AC | 2 ms
6,816 KB |
testcase_06 | AC | 2 ms
6,820 KB |
testcase_07 | AC | 2 ms
6,820 KB |
testcase_08 | AC | 2 ms
6,816 KB |
testcase_09 | AC | 5 ms
6,816 KB |
testcase_10 | AC | 2 ms
6,820 KB |
testcase_11 | AC | 3 ms
6,820 KB |
testcase_12 | AC | 2 ms
6,816 KB |
testcase_13 | AC | 2 ms
6,816 KB |
testcase_14 | AC | 2 ms
6,820 KB |
testcase_15 | AC | 4 ms
6,820 KB |
testcase_16 | AC | 4 ms
6,816 KB |
testcase_17 | AC | 5 ms
6,816 KB |
testcase_18 | AC | 2 ms
6,820 KB |
testcase_19 | AC | 4 ms
6,816 KB |
testcase_20 | AC | 2 ms
6,816 KB |
testcase_21 | AC | 3 ms
6,816 KB |
testcase_22 | AC | 4 ms
6,820 KB |
testcase_23 | AC | 2 ms
6,816 KB |
testcase_24 | WA | - |
testcase_25 | AC | 2 ms
6,820 KB |
testcase_26 | AC | 2 ms
6,816 KB |
testcase_27 | AC | 2 ms
6,816 KB |
testcase_28 | AC | 2 ms
6,820 KB |
testcase_29 | AC | 2 ms
6,816 KB |
testcase_30 | AC | 2 ms
6,816 KB |
testcase_31 | AC | 2 ms
6,816 KB |
testcase_32 | AC | 10 ms
11,264 KB |
ソースコード
// #pragma GCC target("avx2") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; // #include <atcoder/all> // #include <atcoder/fenwicktree> // #include <atcoder/segtree> // #include <atcoder/lazysegtree> // #include <atcoder/string> // #include <atcoder/math> // #include <atcoder/scc> // #include <atcoder/dsu> // using namespace atcoder; // #include <atcoder/modint> // using mint = atcoder::modint998244353; // using mint = atcoder::modint1000000007; // using mint = atcoder::modint; // #include <boost/multiprecision/cpp_int.hpp> // using Bint = boost::multiprecision::cpp_int; // #include <boost/rational.hpp> // using Rat = boost::rational<Bint>; // #include <boost/multiprecision/cpp_dec_float.hpp> // using Real = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1024>>; #ifdef LOCAL #include <library/debug_print.hpp> #define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else #define debug(...) (static_cast<void>(0)) #endif using ll = long long; using ld = long double; const ll INF = 4e18; const int INF_INT = 2e9; using vi = vector<int>; using vd = vector<double>; using vl = vector<ll>; using vvi = vector<vector<int>>; using vvl = vector<vector<ll>>; using vs = vector<string>; using vp = vector<pair<ll, ll>>; using vpc = vector<pair<char, ll>>; using vb = vector<bool>; using vvb = vector<vector<bool>>; using pl = pair<ll, ll>; template <class T> using PQ = priority_queue<T>; template <class T> using GPQ = priority_queue<T, vector<T>, greater<T>>; struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } fast; // interactive #define endl "\n" #define INTYPE(type, ...) type __VA_ARGS__; #define INT(...) INTYPE(int, __VA_ARGS__) IN(__VA_ARGS__) #define LL(...) INTYPE(ll, __VA_ARGS__) IN(__VA_ARGS__) #define STR(...) INTYPE(string, __VA_ARGS__) IN(__VA_ARGS__) #define CHR(...) INTYPE(char, __VA_ARGS__) IN(__VA_ARGS__) #define DBL(...) INTYPE(double, __VA_ARGS__) IN(__VA_ARGS__) #define LD(...) INTYPE(ld, __VA_ARGS__) IN(__VA_ARGS__) #define overload6(_1, _2, _3, _4, _5, _6, name, ...) name #define INVEC(type, ...) vector<type> __VA_ARGS__; #define VEC1(type, name, size) INVEC(type, name(size)) rep(I, size) IN(name[I]) #define VEC2(type, name1, name2, size) INVEC(type, name1(size), name2(size)) rep(I, size) IN(name1[I], name2[I]) #define VEC3(type, name1, name2, name3, size) INVEC(type, name1(size), name2(size), name3(size)) rep(I, size) IN(name1[I], name2[I], name3[I]) #define VEC4(type, name1, name2, name3, name4, size) INVEC(type, name1(size), name2(size), name3(size), name4(size)) rep(I, size) IN(name1[I], name2[I], name3[I], name4[I]); #define VEC(...) overload6(__VA_ARGS__, VEC4, VEC3, VEC2, VEC1)(__VA_ARGS__) #define VV(type, name, h, w) INVEC(vector<type>, name(h, vector<type>(w))) rep(I, h) rep(J, w) IN(name[I][J]); #define vec(type, name, ...) vector<type> name(__VA_ARGS__) #define vv(type, name, h, ...) vector name(h, vector<type>(__VA_ARGS__)) #define vvv(type, name, h, w, ...) vector name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__))) #define overload4(_1, _2, _3, _4, name, ...) name #define rep1(i, n) rep2(i, 0, n) #define rep2(i, a, b) for (ll i = ll(a); i < ll(b); ++i) #define rep3(i, a, b, c) for (ll i = ll(a); i < ll(b); i += ll(c)) #define rep(...) overload4(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__) #define rrep1(i, n) rrep2(i, 0, n) #define rrep2(i, a, b) for (ll i = ll(b) - 1; i >= ll(a); --i) #define rrep3(i, a, b, c) for (ll i = ll(b) - 1; i >= ll(a); i -= ll(c)) #define rrep(...) overload4(__VA_ARGS__, rrep3, rrep2, rrep1)(__VA_ARGS__) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define llacumulate(v) accumulate(all(v), 0LL) #define sz(x) (ll)(x).size() #define ctoi(c) (c - '0') #define itoc(i) (i + '0') #define emp(x) x.empty() #define nmod(x, m) ((x % m + m) % m) #define fi first #define se second #define pf push_front #define ef emplace_front #define pof pop_front #define pb push_back #define eb emplace_back #define pob pop_back #define pc (ll) __builtin_popcountll #define yes cout << "Yes" << endl; #define no cout << "No" << endl; bool yn(bool f) { cout << (f ? "Yes" : "No") << endl; return f; } bool YN(bool f) { cout << (f ? "YES" : "NO") << endl; return f; } bool kaibun(string s) { return s == string(rall(s)); } bool inGrid(ll i, ll j, ll h, ll w) { return i < h && j < w && i >= 0 && j >= 0; } const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; template <class... T> void IN(T &...a) { (cin >> ... >> a); } string toUpper(string s) { rep(i, s.size()) s[i] = toupper(s[i]); return s; } string toLower(string s) { rep(i, s.size()) s[i] = tolower(s[i]); return s; } template <class T> auto min(const T &a) { return *min_element(all(a)); } template <class T> auto max(const T &a) { return *max_element(all(a)); } template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } vector<pair<char, ll>> runLength(const string &str) { ll n = str.size(); vector<pair<char, ll>> res; for (ll l = 0; l < n;) { ll r = l + 1; while (r < n && str[l] == str[r]) ++r; res.emplace_back(str[l], r - l); l = r; } return res; } template <typename T, typename S> int getNearest(const T &a, const vector<S> &v) { int x = lower_bound(all(v), a) - v.begin(), n = v.size(); if (x == 0) return 0; if (x == n) return n - 1; if (abs(v[x] - a) < abs(v[x - 1] - a)) return x; else return x - 1; } template <typename T> vector<pair<ll, ll>> primeFactorize(T n) { vector<pair<ll, ll>> res; for (ll i = 2; i * i <= n; ++i) { if (n % i != 0) continue; ll cnt = 0; while (n % i == 0) { n /= i; ++cnt; } res.emplace_back(i, cnt); } if (n != 1) res.emplace_back(n, 1); return res; } template <typename T> bool isPrime(const T &n) { if (n < 2) return false; if (n == 2) return true; if (n % 2 == 0) return false; for (ll i = 3; i * i <= n; ++i) if (n % i == 0) return false; return true; } vector<bool> eratosthenes(ll n) { vector<bool> v(n + 1, true); v[0] = v[1] = false; for (ll p = 2; p <= n; ++p) { if (!v[p]) continue; for (ll q = p * 2; q <= n; q += p) v[q] = false; } return v; } template <typename T> vector<ll> divisor(T n) { vector<ll> res; for (ll i = 1; i * i <= n; ++i) { if (n % i == 0) { res.emplace_back(i); if (i * i != n) res.emplace_back(n / i); } } sort(res.begin(), res.end()); return res; } ll llpow(ll x, ll n) { if (n == 0) return 1; ll res = llpow(x, n / 2); res *= res; if (n % 2 == 1) res *= x; return res; } template <typename T, typename S> T getCycle(const vector<T> &v, const S &k) { T n = v.size(), s = v.back(), i; for (i = n - 2; i >= 0; --i) { if (v[i] == s) break; } if (k < i) return v[k]; else return v[i + (k - i) % (n - i - 1)]; } void print() { cout << endl; } template <typename T> inline void print(const T &x) { cout << x << endl; } template <class T, class... Ts> void print(const T &a, const Ts &...b) { cout << a; (cout << ... << (cout << ' ', b)); cout << endl; } template <typename T> inline void print(const vector<T> &v) { rep(i, v.size()) { if (i != (ll)v.size() - 1) cout << v[i] << " "; else cout << v[i] << endl; } } template <typename T> inline void print(const vector<vector<T>> &v) { for (auto &&p : v) print(p); } template <typename T, typename S> inline void print(const pair<T, S> &p) { cout << p.first << " " << p.second << endl; } template <typename T, typename S> inline void print(const vector<pair<T, S>> &v) { for (auto &&p : v) print(p); } int main() { LL(n, p, k); VEC(ll, t, b, n); vv(ll, dp, n + 1, k + 10, -INF); dp[0][0] = p; const ll m = 1e18 + 1; rep(i, n) { rep(j, k + 1) { if (dp[i][j] == -INF) continue; // 選ぶ if (t[i] == 1) chmax(dp[i + 1][j + 1], min(m, dp[i][j] + b[i])); else chmax(dp[i + 1][j + 1], min(m, dp[i][j] * 2)); // 選ばない chmax(dp[i + 1][j], dp[i][j]); } } debug(dp); ll ans = -INF; rep(i, n + 1) chmax(ans, dp[i][k]); if (ans == m) ans = -1; print(ans); }