結果

問題 No.2622 Dam
ユーザー 寝癖寝癖
提出日時 2024-02-09 21:41:56
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,594 bytes
コンパイル時間 2,873 ms
コンパイル使用メモリ 245,192 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-09 21:41:59
合計ジャッジ時間 2,782 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

using namespace std;
// using namespace atcoder;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

template <class T> using Vec = vector<T>;
template <class T> using Graph = Vec<Vec<T>>;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,n-1,-1)
#define rrepi(i,a,b) for(int i=int(a);i>int(b);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep)(__VA_ARGS__)

#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REVERSE(x) reverse(all(x))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void solve(ll V, ll X, ll Fo, ll Fi, ll Q, ll R) {
  ll D = R*(Fi-Fo)-(Q-R)*Fo;
  if (D == 0) {
    if (X + R*(Fi-Fo) > V) cout << "Overflow" << endl;
    else if (X + R*(Fi-Fo) <= 0) cout << "Zero" << endl;
    else cout << "Safe" << endl;
  } else if (D > 0) {
    if (X + R*(Fi-Fo) <= 0) cout << "Zero" << endl;
    else cout << "Overflow" << endl;
  } else {
    if (X + R*(Fi-Fo) > V) cout << "Overflow" << endl;
    else cout << "Zero" << endl;
  }
}

int main() {
  int T;
  cin >> T;

  rep(i, T) {
    ll V, X, Fo, Fi, Q, R;
    cin >> V >> X >> Fo >> Fi >> Q >> R;
    solve(V, X, Fo, Fi, Q, R);
  }
}
0