結果

問題 No.3068 Speedrun (Hard)
ユーザー srjywrdnprkt
提出日時 2025-03-21 23:02:41
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,338 ms / 2,000 ms
コード長 1,262 bytes
コンパイル時間 4,056 ms
コンパイル使用メモリ 275,048 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-21 23:02:57
合計ジャッジ時間 15,778 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/modint>

using namespace std;
//using namespace atcoder;
using ll = long long;
//using mint = modint998244353;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    ll N, a[4], b[4], x, y, T, S, M;
    for (int i=0; i<4; i++) cin >> a[i];
    cin >> N;
    for (int i=0; i<4; i++) cin >> b[i];
    cin >> T;

    for (ll i=0; i<=a[2]; i++){
        for (ll j=0; j<=a[3]; j++){
            S = T-b[2]*i-b[3]*j;
            M = N-i-j;
            if (S < 0 || M < 0) continue;
            if (b[0] != b[1]){
                if ((S-M*b[0]) % (b[1]-b[0]) != 0) continue;
                y = (S-M*b[0])/(b[1]-b[0]);
                x = M-y;
                if (0<=x && x<=a[0] && 0<=y && y<=a[1]){
                    cout << x << " " << y << " " << i << " " << j << endl;
                    return 0;
                }
            }
            else{
                if (S/b[0] != M) continue;
                x = min(M, a[0]);
                y = M-x;
                if (0<=x && x<=a[0] && 0<=y && y<=a[1]){
                    cout << x << " " << y << " " << i << " " << j << endl
;
                    return 0;
                }
            }
        }
    }
    assert(0);

    return 0;
}
0