結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
9,984 KB
testcase_01 WA -
testcase_02 AC 29 ms
9,984 KB
testcase_03 AC 30 ms
9,984 KB
testcase_04 WA -
testcase_05 AC 29 ms
9,984 KB
testcase_06 WA -
testcase_07 AC 29 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 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 30 ms
9,984 KB
testcase_27 AC 30 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,0)
            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+min(-(W//N+1)+A,0)
                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,0)
    else:
        ans=":("
    print(ans)
0