結果

問題 No.3023 Utility is Max?
ユーザー ArcAki
提出日時 2025-04-17 06:57:20
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 94 ms / 1,000 ms
コード長 1,151 bytes
コンパイル時間 3,940 ms
コンパイル使用メモリ 274,468 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-17 06:57:28
合計ジャッジ時間 6,854 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

// GPT-o4-mini-highの実験

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

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

    int Q;
    cin >> Q;
    while(Q--){
        int64 I;
        cin >> I;

        int64 A1,B1,X1,Y1;
        int64 A2,B2,X2,Y2;
        cin >> A1 >> B1 >> X1 >> Y1
            >> A2 >> B2 >> X2 >> Y2;

        // ① 各店で予算を使い切っているか
        int64 cost1 = A1*X1 + B1*Y1;
        int64 cost2 = A2*X2 + B2*Y2;
        if(cost1 != I || cost2 != I){
            cout << "No\n";
            continue;
        }

        // 他方の店で相手のバンドルが買えてしまうか
        int64 cross12 = A1*X2 + B1*Y2;  // 店1で bundle2 が買えるか
        int64 cross21 = A2*X1 + B2*Y1;  // 店2で bundle1 が買えるか

        // 両方のクロスコストが予算以下 かつ どちらか一方でも厳密に予算より少ない → 循環するので NG
        if(cross12 <= I && cross21 <= I && (cross12 < I || cross21 < I)){
            cout << "No\n";
        } else {
            cout << "Yes\n";
        }
    }
    return 0;
}
0