結果
問題 | No.2390 Udon Coupon (Hard) |
ユーザー |
![]() |
提出日時 | 2023-07-21 22:05:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 64 ms / 2,000 ms |
コード長 | 908 bytes |
コンパイル時間 | 2,047 ms |
コンパイル使用メモリ | 200,684 KB |
最終ジャッジ日時 | 2025-02-15 16:56:35 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 47 |
ソースコード
#include <bits/stdc++.h>using namespace std;#ifdef tabr#include "library/debug.cpp"#else#define debug(...)#endifint main() {ios::sync_with_stdio(false);cin.tie(nullptr);long long n;cin >> n;vector<pair<int, int>> c(3);for (int i = 0; i < 3; i++) {cin >> c[i].first >> c[i].second;}sort(c.begin(), c.end(), [&](auto x, auto y) {return x.second * y.first < y.second * x.first;});vector<long long> a(3), b(3);for (int i = 0; i < 3; i++) {a[i] = c[i].first;b[i] = c[i].second;}long long ans = 0;for (int i = 0; i < 2023; i++) {for (int j = 0; j < 2023; j++) {if (a[0] * i + a[1] * j > n) {break;}ans = max(ans, b[0] * i + b[1] * j + b[2] * ((n - a[0] * i - a[1] * j) / a[2]));}}cout << ans << '\n';return 0;}