結果
問題 |
No.1972 Modulo Set
|
ユーザー |
![]() |
提出日時 | 2022-06-13 17:07:40 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 551 bytes |
コンパイル時間 | 258 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 108,028 KB |
最終ジャッジ日時 | 2024-09-25 11:26:51 |
合計ジャッジ時間 | 7,765 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 13 |
ソースコード
N,M = map(int,input().split()) A = list(map(int,input().split())) dict = {} for i,v in enumerate(A): tmp =v%M if tmp not in dict: dict[tmp] = 1 else: dict[tmp]+=1 tmp = [] for i,v in dict.items(): tmp.append([v,i]) tmp.sort() tmp.reverse() #print(tmp) ans = 0 #print(dict) for i,v in enumerate(tmp): a,b = v[0],v[1] if b*2 == M: ans+=1 else: #print("a=",a,"b=",b) #print("dict[b]",dict[b]) ans+=dict[b] if (M-b) in dict: dict[M-b] = 0 print(ans)