結果
問題 | No.3068 Speedrun (Hard) |
ユーザー |
👑 ![]() |
提出日時 | 2025-02-19 00:24:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 523 ms / 2,000 ms |
コード長 | 1,691 bytes |
コンパイル時間 | 690 ms |
コンパイル使用メモリ | 67,452 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-02-19 00:24:19 |
合計ジャッジ時間 | 5,433 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 |
ソースコード
#include <iostream>using namespace std;int main() {int A, B, C, D, N;cin >> A >> B >> C >> D >> N;int P, Q, R, S, T;cin >> P >> Q >> R >> S >> T;for (int a = 0; a <= A; a++) {for (int b = 0; b <= B; b++) {int rem_n = N - a - b;int rem_t = T - a * P - b * Q;// c + d = rem_n// cR + dS = rem_tif (R == S) {if (rem_n * R != rem_t) {continue;} else {if (C + D < rem_n) {continue;} else {int nc = min(C, rem_n);cout << a << " " << b << " " << nc << " " << rem_n - nc<< endl;return 0;}}} else if (R < S) {if ((rem_n * S - rem_t) % (S - R) != 0) {continue;}int c = (rem_n * S - rem_t) / (S - R);int d = rem_n - c;if (c >= 0 && c <= C && d >= 0 && d <= D) {cout << a << " " << b << " " << c << " " << d << endl;return 0;}} else {if ((rem_t - rem_n * S) % (R - S) != 0) {continue;}int c = (rem_t - rem_n * S) / (R - S);int d = rem_n - c;if (c >= 0 && c <= C && d >= 0 && d <= D) {cout << a << " " << b << " " << c << " " << d << endl;return 0;}}}}}