結果
問題 | No.3068 Speedrun (Hard) |
ユーザー |
![]() |
提出日時 | 2025-03-21 22:23:59 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,331 ms / 2,000 ms |
コード長 | 1,379 bytes |
コンパイル時間 | 842 ms |
コンパイル使用メモリ | 83,920 KB |
実行使用メモリ | 7,324 KB |
最終ジャッジ日時 | 2025-03-21 22:24:18 |
合計ジャッジ時間 | 12,502 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 |
ソースコード
#include <iostream> #include <vector> #include <array> #include <cassert> using namespace std; typedef long long ll; int main() { ll A, B, C, D, N; cin >> A >> B >> C >> D >> N; ll P, Q, R, S, T; cin >> P >> Q >> R >> S >> T; for (ll i = 0; i <= A; i++) { for (ll j = 0; j <= B; j++) { ll U = T - i * P - j * Q; ll M = N - i - j; if (U < 0 || M < 0) { continue; } if (U == 0 && M == 0) { cout << i << ' ' << j << ' ' << 0 << ' ' << 0 << '\n'; exit(0); } if (R == S && (U % R) == 0 && U / R == M && U / R <= C + D) { ll tmp = U / R; if (tmp <= C) { cout << i << ' ' << j << ' ' << tmp << ' ' << 0 << '\n'; exit(0); } else { cout << i << ' ' << j << ' ' << C << ' ' << tmp - C << '\n'; exit(0); } } if (R == S) { continue; } ll tmp1 = (U - M*R), tmp2 = (S - R); if (tmp1 % tmp2 == 0) { ll nc, nd; nd = tmp1 / tmp2; nc = M - nd; if (0 <= nc && nc <= C && 0 <= nd && nd <= D) { cout << i << ' ' << j << ' ' << nc << ' ' << nd << '\n'; exit(0); } } } } assert(0); return 0; } /* File : ~/yukicoder/530/E.cpp Date : 2025/03/21 Time : 21:47:43 */