結果

問題 No.11 カードマッチ
ユーザー masumasumath1masumasumath1
提出日時 2019-12-04 19:56:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 691 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 10,772 KB
実行使用メモリ 7,968 KB
最終ジャッジ日時 2023-08-21 00:52:14
合計ジャッジ時間 1,839 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,808 KB
testcase_01 AC 16 ms
7,836 KB
testcase_02 AC 16 ms
7,840 KB
testcase_03 WA -
testcase_04 AC 16 ms
7,860 KB
testcase_05 AC 15 ms
7,836 KB
testcase_06 WA -
testcase_07 AC 16 ms
7,792 KB
testcase_08 WA -
testcase_09 AC 16 ms
7,840 KB
testcase_10 AC 16 ms
7,792 KB
testcase_11 AC 15 ms
7,808 KB
testcase_12 AC 16 ms
7,912 KB
testcase_13 AC 16 ms
7,872 KB
testcase_14 AC 16 ms
7,968 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

W = int(input())#マークの種類
H = int(input())#数字カードの最大値
N = int(input())
SK = [0 for _ in range(N)]
A = set()
B = set()
for i in range(N):
    a,b = map(int,input().split())
    A.add(a)
    B.add(b)
    SK[i] = [a,b]
#マーク順に並べる
SK.sort()
ans = 0
i = 0
while i < N:
    s = SK[i][0]
    k = SK[i][1]
    cntK = 1
    i += 1
    if i == N:
        ans += H-cntK
        break
    #マークが同じカードが何枚あるかをcntに格納
    while SK[i][0] == s:
        cntK += 1
        i += 1
        if i == N:
            ans += H-cntK
            break
    ans += H-cntK if i != N else 0
if W > len(B):
    ans += (W-len(B))*len(A)
print(ans)
0