結果

問題 No.3068 Speedrun (Hard)
ユーザー t98slider
提出日時 2025-03-21 23:29:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,151 bytes
コンパイル時間 2,372 ms
コンパイル使用メモリ 195,780 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2025-03-21 23:29:54
合計ジャッジ時間 13,056 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<class T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll t, n;
    vector<ll> a(4), b(4);
    cin >> a >> n >> b >> t;
    const ll d = b[2] - b[3];
    for(ll i = 0; i <= n && i <= a[0] && i * b[0] <= t; i++){
        for(ll j = 0; i + j <= n && j <= a[1] && i * b[0] + j * b[1] <= t; j++){
            ll rt = t - (i * b[0] + j * b[1]);
            ll r = n - (i + j);
            // Ax + B * (r - x) = rt
            // (A - B) * x + B * r == rt
            ll rhs = rt - b[3] * r;
            if(rhs == 0 && 0 <= r && r <= a[3]){
                cout << i << " " << j << " " << 0 << " " << r << '\n';
                return 0;
            }
            if(d == 0) continue;
            if(rhs % d != 0) continue;
            ll c2 = rhs / d, c3 = r - c2;
            if(0 <= c2 && c2 <= a[2] && 0 <= c3 && c3 <= a[3]){
                cout << i << " " << j << " " << c2 << " " << c3 << '\n';
                return 0;
            }
        }
    }
}
0