結果

問題 No.2493 K-th in L2 with L1
ユーザー titiatitia
提出日時 2023-10-06 21:40:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 380 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 10,748 KB
実行使用メモリ 8,360 KB
最終ジャッジ日時 2023-10-06 21:40:09
合計ジャッジ時間 927 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,360 KB
testcase_01 AC 30 ms
8,264 KB
testcase_02 AC 30 ms
8,268 KB
testcase_03 AC 29 ms
8,352 KB
testcase_04 AC 17 ms
7,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from operator import itemgetter

Q=int(input())
for tests in range(Q):
    D,K=map(int,input().split())

    LIST=set()

    for i in range(-D,D+1):
        y=D-abs(i)

        LIST.add((i,y,i*i+y*y))
        LIST.add((i,-y,i*i+y*y))

    LIST=sorted(LIST,key=itemgetter(2))

    if K-1>=len(LIST):
        print("No")
    else:
        print("Yes")
        print(*LIST[K-1][:2])
0