結果
問題 |
No.2390 Udon Coupon (Hard)
|
ユーザー |
👑 |
提出日時 | 2023-07-04 01:52:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 648 bytes |
コンパイル時間 | 418 ms |
コンパイル使用メモリ | 57,120 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-06 01:35:47 |
合計ジャッジ時間 | 2,001 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 47 |
ソースコード
#include <algorithm> // max #include <iostream> // cin, cout, endl #include <utility> // swap using ll = long long; int main() { ll n, a1, b1, a2, b2, a3, b3; std::cin >> n >> a1 >> b1 >> a2 >> b2 >> a3 >> b3; if (a2 * b1 < a1 * b2) { std::swap(a1, a2); std::swap(b1, b2); } if (a3 * b1 < a1 * b3) { std::swap(a1, a3); std::swap(b1, b3); } ll r = 0, a1b2 = a1 * std::max(b2, 1LL), a1b3 = a1 * std::max(b3, 1LL); for (ll p = 0, s = n; p < a1b2 && s >= 0; p += b2, s -= a2) { for (ll q = 0, t = s; q < a1b3 && t >= 0; q += b3, t -= a3) { r = std::max(r, t / a1 * b1 + p + q); } } std::cout << r << std::endl; return 0; }