結果

問題 No.1440 The Quiz Competition
ユーザー vwxyzvwxyz
提出日時 2023-11-28 14:04:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 909 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2023-11-28 14:04:31
合計ジャッジ時間 2,503 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import sys
readline=sys.stdin.readline

T=int(readline())
for t in range(T):
    N,A,W,K=map(int,readline().split())
    if K-1<=A or N-K+1<=W:
        if K<N:
            ans=(A-(K-1))//K
        else:
            if W%N==0:
                if A>=K-1:
                    ans=-(W//N)*(W//N+1)//2+(A-(K-1))//K
                else:
                    ans=-(W//N)*(W//N+1)//2+min(-(W//N+1)+A,-1)
            else:
                if W%N*(W//N+1)<=A:
                    A-=W%N*(W//N+1)
                    if A>=K-1:
                        ans=-(W//N)*(W//N+1)//2+(A-(K-1))//K
                    else:
                        ans=-(W//N)*(W//N+1)//2-1
                else:
                    if A>=K-1:
                        ans=-(W//N+1)*(W//N+2)//2+(A-(K-1))//K
                    else:
                        ans=-(W//N+1)*(W//N+2)//2+min(-(W//N+1)+A,-1)
    else:
        ans=":("
    print(ans)

0