結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 3 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef Kaushal_26
        #include <debug.h>
#else
        #include <bits/stdc++.h>

        using namespace std;

        #define clog                    if (0) cerr
        #define lvl(...)                42
        #define dbg(...)                42
#endif

#define overload5(a, b, c, d, e, ...)   e
#define FORS(i, a, b, c)                for(int i = (a); i < (int)(b); i += c)
#define FOR1(i, a, b)                   for(int i = (a); i < (int)(b); ++i)
#define F0R(i, a)                       for(int i = (0); i < (int)(a); ++i)
#define ROFS(i, a, b, c)                for(int i = (b) - 1; i >= (int)(a); i -= c)
#define ROF1(i, a, b)                   for(int i = (b) - 1; i >= (int)(a); --i)
#define R0F(i, a)                       for(int i = (a) - 1; i >= (int)(0); --i)
#define FOR(...)                        overload5(__VA_ARGS__, FORS, FOR1, F0R)(__VA_ARGS__)
#define ROF(...)                        overload5(__VA_ARGS__, ROFS, ROF1, R0F)(__VA_ARGS__)
#define REP(i, x)                       for(auto &i : x)

#define int                             long long

template <class T> auto V(const T& value, int size) {
        return vector<T>(size, value);
}

template <class T, class... D> auto V(const T& value, int size, D... w) {
        auto W = V(value, w...); 
        return vector<decltype(W)>(size, W);
}

template <class T> bool ckmin(T &a, T &b) {
        return b < a ? a = b, 1 : 0;
}

template <class T> bool ckmax(T &a, T &b) {
        return b > a ? a = b, 1 : 0;
}

void solve() {
        int V, X, F0, Fi, Q, R; cin >> V >> X >> F0 >> Fi >> Q >> R;

        int nX = X + Fi * R - F0 * R;
        if(nX > V) {
                cout << "Overflow\n";
                return;
        } else if(nX <= 0) {
                cout << "Zero\n";
                return;
        }

        nX -= (Q - R) * F0;
        if(nX == X) {
                cout << "Safe\n";
        } else if(nX > X) {
                cout << "Overflow\n";
        } else {
                cout << "Zero\n";
        }
}

signed main() {
        #ifdef Kaushal_26
                auto begin = std::chrono::high_resolution_clock::now();
        #endif

        cin.tie(0) -> sync_with_stdio(0);

        int TestCases = 1; cin >> TestCases;
        for(int TestCase = 1; TestCase <= TestCases; TestCase++) {
                clog << "\n"; dbg(TestCase);
                solve();
        }

        #ifdef Kaushal_26
                auto end = std::chrono::high_resolution_clock::now();
                clog << fixed << setprecision(15) << "\n";
                auto Execution_Time = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin).count() * 1e-9;
                dbg(Execution_Time);
        #endif
        return 0;
}

// 1.77245
0