結果

問題 No.2622 Dam
ユーザー tnakao0123tnakao0123
提出日時 2024-02-16 22:19:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 664 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 40,640 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-16 22:19:36
合計ジャッジ時間 976 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2622.cc:  No.2622 Dam - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  int tn;
  scanf("%d", &tn);

  while (tn--) {
    ll v, x;
    int fo, fi, q, r;
    scanf("%lld%lld%d%d%d%d", &v, &x, &fo, &fi, &q, &r);

    ll s = x;
    s += (ll)(fi - fo) * r;
    if (s > v) { puts("Overflow"); continue; }
    s -= (ll)fo * (q - r);
    if (s <= 0) { puts("Zero"); continue; }

    if (s > x) puts("Overflow");
    else if (s < x) puts("Zero");
    else puts("Safe");
  }

  return 0;
}
0