結果
問題 | No.2390 Udon Coupon (Hard) |
ユーザー | mayocorn |
提出日時 | 2023-07-21 22:36:19 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,138 bytes |
コンパイル時間 | 4,449 ms |
コンパイル使用メモリ | 265,276 KB |
実行使用メモリ | 42,480 KB |
最終ジャッジ日時 | 2024-09-22 00:04:23 |
合計ジャッジ時間 | 7,495 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,812 KB |
testcase_01 | AC | 3 ms
6,940 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 52 ms
42,240 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 53 ms
42,292 KB |
testcase_10 | AC | 4 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 3 ms
5,376 KB |
testcase_13 | AC | 3 ms
5,376 KB |
testcase_14 | AC | 3 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 3 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 3 ms
5,376 KB |
testcase_19 | AC | 3 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 2 ms
5,376 KB |
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 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 34 ms
32,000 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 55 ms
42,240 KB |
testcase_43 | WA | - |
testcase_44 | AC | 52 ms
42,112 KB |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; // type typedef long long ll; typedef long double ld; using i128 = __int128_t; template<class T> using pq = priority_queue<T>; template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>; template<class T> using v = vector<T>; #define V vector #define pl pair<ll, ll> #define vl v<ll> #define vp v<pl> #define vm v<mint> // IN-OUT #define NYAN ios::sync_with_stdio(false);cin.tie(nullptr);cout<<fixed<<setprecision(15); ostream &operator<<(ostream &os, const i128 &v) { if(v == 0) { return (os << "0"); } i128 num = v; if(v < 0) { os << '-'; num = -num; } string s; for(; num > 0; num /= 10) { s.push_back((char)(num % 10) + '0'); } reverse(s.begin(), s.end()); return (os << s); } void Yes(bool b=1) { cout << ( b == 1 ? "Yes" : "No" ) << "\n"; } void YES(bool b=1) { cout << ( b == 1 ? "YES" : "NO" ) << "\n"; } void No(bool b=1) { cout << ( b == 1 ? "No" : "Yes" ) << "\n"; } void NO(bool b=1) { cout << ( b == 1 ? "NO" : "YES" ) << "\n"; } void CIN() {} template <typename T, class... U> void CIN(T &t, U &...u) { cin >> t; CIN(u...); } void COUT() { cout << "\n"; } template <typename T, class... U, char sep = ' '> void COUT(const T &t, const U &...u) { cout << t; if (sizeof...(u)) cout << sep; COUT(u...); } #define dump(x) cerr << #x << ":"<< x << "\n"; #define vdump(x) rep(repeat, sz(x)) cerr << repeat << ":" << x[repeat] << "\n"; // macro #define bp __builtin_popcountll #define ALL(x) x.begin(),x.end() #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define reps(i, s, n) for (ll i = s; i < (ll)(n); i++) #define sz(x) (ll)x.size() ll xd[]={0, 1, 0, -1, 1, 1, -1, -1}; ll yd[]={1, 0, -1, 0, 1, -1, -1, 1}; // function template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } template<typename T>int bl(T x) { int s = 0; while(x) {x >>= 1; s++;} return s; } // bitlength ll rmax(ll a, ll b){return max(a, b);} ll rmin(ll a, ll b){return min(a, b);} ll rsum(ll a, ll b){return a + b;} ll rzero(){return 0;} // constant long double PI = 3.14159265358979; #define INF32 2147483647 #define INF64 9223372036854775807 #define INF 922337203685477580 using mint = modint998244353; // using mint = modint1000000007; /* SOLVE BEGIN ************************************************************************** */ void solve() { ll n; cin >> n; vl a(3), b(3); rep(i, 3) cin >> a[i] >> b[i]; const ll d = 5000010; if(n < d){ vl dp(n + 1, -1); dp[0] = 0; rep(i, 3){ rep(j, n){ ll nx = a[i] + j; if(nx > n) break; if(dp[j] != -1) chmax(dp[nx], dp[j] + b[i]); } } cout << *max_element(ALL(dp)) << "\n"; return; } vl dp(d, -1); rep(i, 3){ rep(j, d){ chmax(dp[j], (n - (d - i - 1)) / a[i] * b[i]); ll nx = a[i] + j; if(nx < d){ chmax(dp[nx], dp[j] + b[i]); } } } cout << *max_element(ALL(dp)) << "\n"; } int main() { NYAN solve(); return 0; }