結果
| 問題 |
No.1440 The Quiz Competition
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2021-03-26 21:44:28 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 790 bytes |
| コンパイル時間 | 496 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-11-28 22:29:47 |
| 合計ジャッジ時間 | 2,215 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 WA * 24 |
ソースコード
import sys
input = sys.stdin.readline
T=int(input())
for tests in range(T):
N,A,W,K=map(int,input().split())
if K!=N:
OK=-2
NG=1<<60
while NG-OK>1: # K-1人がOK+1点、一人がOK取れるか?
mid=(OK+NG)//2
if (mid+1)*(K-1)+mid<=A:
OK=mid
else:
NG=mid
if OK>=0:
print(OK)
continue
if W>=N-K:
print(-1)
continue
else:
print(":(")
continue
ANS=A//N
MINUS=(W+N-1)//N
ANS-=MINUS*(MINUS+1)//2
if A%N==N-1 or W%N==1:
print(ANS)
elif A>=N-1:
print(ANS-1)
elif W>=2:
print(A//N-(MINUS+1)*(MINUS+2)//2)
else:
print(":(")
titia