結果

問題 No.3023 Utility is Max?
ユーザー ArcAki
提出日時 2025-01-12 03:42:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,074 bytes
コンパイル時間 775 ms
コンパイル使用メモリ 82,232 KB
実行使用メモリ 81,352 KB
最終ジャッジ日時 2025-01-12 03:42:54
合計ジャッジ時間 6,652 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 1 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

# GPT-o1 生成コード


def solve():
    import sys
    input = sys.stdin.readline
    
    Q = int(input())
    ans = []
    
    for _ in range(Q):
        I = int(input())
        
        A1, B1, X1, Y1 = map(int, input().split())
        A2, B2, X2, Y2 = map(int, input().split())
        
        cost1 = A1*X1 + B1*Y1
        cost2 = A2*X2 + B2*Y2
        
        # 1) 店1・店2でピッタリか?
        if cost1 != I or cost2 != I:
            ans.append("No")
            continue
        
        # 2) もし同じ点なら矛盾なし
        if (X1 == X2) and (Y1 == Y2):
            ans.append("Yes")
            continue
        
        # 3) クロスチェック
        c12 = A1*X2 + B1*Y2  # 店1制約における (X2,Y2) の費用
        c21 = A2*X1 + B2*Y1  # 店2制約における (X1,Y1) の費用
        
        # 両方同時に "予算内" (<= I) なら矛盾
        if c12 <= I and c21 <= I:
            ans.append("No")
        else:
            ans.append("Yes")
    
    print("\n".join(ans))


if __name__ == "__main__": solve()
0