結果

問題 No.1972 Modulo Set
ユーザー terasaterasa
提出日時 2022-06-10 22:14:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 1,194 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 82,504 KB
実行使用メモリ 132,004 KB
最終ジャッジ日時 2024-04-15 08:51:22
合計ジャッジ時間 5,629 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
55,068 KB
testcase_01 AC 47 ms
55,688 KB
testcase_02 AC 48 ms
55,156 KB
testcase_03 AC 72 ms
72,732 KB
testcase_04 AC 73 ms
75,648 KB
testcase_05 AC 73 ms
76,568 KB
testcase_06 AC 120 ms
83,716 KB
testcase_07 AC 104 ms
89,580 KB
testcase_08 AC 70 ms
75,708 KB
testcase_09 AC 62 ms
66,904 KB
testcase_10 AC 73 ms
76,744 KB
testcase_11 AC 101 ms
87,956 KB
testcase_12 AC 72 ms
73,760 KB
testcase_13 AC 64 ms
68,876 KB
testcase_14 AC 64 ms
68,764 KB
testcase_15 AC 116 ms
89,516 KB
testcase_16 AC 117 ms
93,372 KB
testcase_17 AC 81 ms
79,740 KB
testcase_18 AC 48 ms
55,900 KB
testcase_19 AC 115 ms
92,632 KB
testcase_20 AC 122 ms
95,584 KB
testcase_21 AC 89 ms
82,408 KB
testcase_22 AC 104 ms
91,648 KB
testcase_23 AC 159 ms
116,572 KB
testcase_24 AC 97 ms
95,084 KB
testcase_25 AC 127 ms
98,536 KB
testcase_26 AC 121 ms
91,956 KB
testcase_27 AC 174 ms
122,508 KB
testcase_28 AC 101 ms
95,992 KB
testcase_29 AC 119 ms
108,948 KB
testcase_30 AC 145 ms
108,740 KB
testcase_31 AC 62 ms
68,356 KB
testcase_32 AC 137 ms
104,808 KB
testcase_33 AC 186 ms
131,884 KB
testcase_34 AC 182 ms
131,632 KB
testcase_35 AC 186 ms
131,728 KB
testcase_36 AC 182 ms
132,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict
import bisect

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
pypyjit.set_param('max_unroll_recursion=-1')


def index_lt(a, x):
    'return largest index s.t. A[i] < x or -1 if it does not exist'
    return bisect.bisect_left(a, x) - 1


def index_le(a, x):
    'return largest index s.t. A[i] <= x or -1 if it does not exist'
    return bisect.bisect_right(a, x) - 1


def index_gt(a, x):
    'return smallest index s.t. A[i] > x or len(a) if it does not exist'
    return bisect.bisect_right(a, x)


def index_ge(a, x):
    'return smallest index s.t. A[i] >= x or len(a) if it does not exist'
    return bisect.bisect_left(a, x)


N, M = map(int, input().split())
A = list(map(int, input().split()))

D = defaultdict(int)
checked = set()
zero = 0
for a in A:
    p = a % M
    if p == 0:
        zero = 1
        continue
    D[a % M] += 1
    D[M - a % M] += 0
ans = 0
for k in D.keys():
    if k in checked:
        continue
    checked.add(k)
    checked.add(M - k)
    if k == M - k:
        ans += 1
    else:
        ans += max(D[k], D[M - k])
print(ans + zero)
0