結果

問題 No.3068 Speedrun (Hard)
ユーザー kenti
提出日時 2025-03-23 19:20:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,159 ms / 2,000 ms
コード長 1,115 bytes
コンパイル時間 2,180 ms
コンパイル使用メモリ 194,548 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2025-03-23 19:20:54
合計ジャッジ時間 9,243 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    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 (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            int res = t - s * n - (p - s) * i - (q - s) * j;
            if (r - s == 0) {
                if (res == 0 && i + j + c + d >= n) {
                    if (i + j + c >= n) {
                        cout << i << " " << j << " " << n - i - j << " " << 0 << "\n";
                    } else {
                        cout << i << " " << j << " " << c << " " << n - i - j - c << "\n";
                    }
                    return 0;
                }
            } else if (res % (r - s) == 0) {
                int k = res / (r - s), l = n - i - j - k;
                if (k >= 0 && k <= c && l >= 0 && l <= d) {
                    cout << i << " " << j << " " << k << " " << l << "\n";
                    return 0;
                }
            }
        }
    }
    return 0;
}
0