結果

問題 No.2622 Dam
ユーザー nwonwo
提出日時 2024-02-09 21:32:46
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 879 bytes
コンパイル時間 4,926 ms
コンパイル使用メモリ 308,364 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-09 21:32:52
合計ジャッジ時間 5,478 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ld = long double;
using ll = long long;

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

using P = pair<int,int>;

int main()
{
	int T;
	cin >> T;
	while(T--)
	{
		ll V, X, out, in, Q, R;
		cin >> V >> X >> out >> in >> Q >> R;
		ll a = X + (in-out)*R;
		if(a>V)
		{
			cout << "Overflow" << endl;
			continue;
		}
		else if(a<=0)
		{
			cout << "Zero" << endl;
			continue;
		}
		ll b = a - out*(Q-R);
		if(b==X)
		{
			cout << "Safe" << endl;
			continue;
		}
		if(b>X)
		{
			cout << "Overflow" << endl;
			continue;
		}
		if(b<X)
		{
			cout << "Zero" << endl;
			continue;
		}
	}
}
0