結果

問題 No.1440 The Quiz Competition
コンテスト
ユーザー first_vil
提出日時 2021-02-09 13:53:49
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 1,346 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 6,303 ms
コンパイル使用メモリ 336,572 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-06-17 18:12:50
合計ジャッジ時間 7,949 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 1
other RE * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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