結果

問題 No.1440 The Quiz Competition
ユーザー first_vilfirst_vil
提出日時 2021-02-09 13:53:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,346 bytes
コンパイル時間 6,982 ms
コンパイル使用メモリ 303,976 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-30 12:59:07
合計ジャッジ時間 8,065 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

#include "testlib.h"
int main() {
    init();
    registerValidation();

    int t = inf.readInt(1, 100);
    inf.readEoln();

    ll n_sum = 0;
    while (t--) {
        ll n = inf.readInt(2, 200000);
        inf.readSpace();
        n_sum += n;

        ll a = inf.readInt(0, 1000000000);
        inf.readSpace();
        ll w = inf.readInt(0, 1000000000);
        inf.readSpace();
        ll k = inf.readInt(1, n);
        inf.readEoln();

        if (a < k - 1 && w < n - k + 1) {
            cout << ":(\n";
            continue;
        }

        ll ans;
        if (k == n) {
            ll c = (w + n - 1) / n, f = w / n;
            ll x = w % n, y = n - x;
            ll xw = -c * (c + 1) / 2, yw = -f * (f + 1) / 2;
            if (x == 0) {
                if (a < n - 1)ans = min(yw - (f + 1) + a, yw - 1);
                else ans = yw + a / n;
            }
            else {
                if (a < x - 1)ans = min(xw - (c + 1) + a, xw - 1);
                else {
                    if (a <= c * x - 1)ans = xw + a / x;
                    else ans = yw - 1 + (a - (c * x - 1)) / n;
                }
            }
        }
    }
}
0