結果
| 問題 | No.1083 余りの余り | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-06-19 23:00:49 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 57 ms / 3,000 ms | 
| コード長 | 684 bytes | 
| コンパイル時間 | 243 ms | 
| コンパイル使用メモリ | 82,096 KB | 
| 実行使用メモリ | 68,956 KB | 
| 最終ジャッジ日時 | 2024-07-03 15:28:15 | 
| 合計ジャッジ時間 | 2,494 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 31 | 
ソースコード
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
nax = 0
from collections import deque
import bisect
for i in range(n):
    u = a[:i]
    crt = k % a[i]
    # print(a[i], crt)
    for j in range(n):
        if crt < a[j]:
            u = a[:j]
            break
    # print(u)
    q = deque([])
    q.append((crt, u))
    while q:
        now = q.popleft()
        if not now[1]:
            nax = max(nax, now[0])
        else:
            for j in range(len(now[1])):
                crt = now[0] % now[1][j]
                t = bisect.bisect_right(now[1], crt)
                q.append((crt, now[1][:t]))
    #     print(q)
    # print(nax)
print(nax)
            
            
            
        