結果

問題 No.1623 三角形の制作
ユーザー brthyyjpbrthyyjp
提出日時 2021-07-23 22:07:21
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 517 ms / 2,000 ms
コード長 809 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 86,748 KB
実行使用メモリ 159,380 KB
最終ジャッジ日時 2023-09-25 22:11:22
合計ジャッジ時間 8,006 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
76,428 KB
testcase_01 AC 96 ms
76,304 KB
testcase_02 AC 517 ms
128,336 KB
testcase_03 AC 467 ms
127,968 KB
testcase_04 AC 464 ms
127,856 KB
testcase_05 AC 514 ms
159,380 KB
testcase_06 AC 409 ms
86,188 KB
testcase_07 AC 465 ms
127,612 KB
testcase_08 AC 420 ms
88,940 KB
testcase_09 AC 466 ms
121,908 KB
testcase_10 AC 503 ms
152,516 KB
testcase_11 AC 475 ms
135,032 KB
testcase_12 AC 132 ms
103,300 KB
testcase_13 AC 143 ms
111,792 KB
testcase_14 AC 139 ms
107,560 KB
testcase_15 AC 204 ms
157,788 KB
testcase_16 AC 203 ms
158,032 KB
testcase_17 AC 204 ms
157,728 KB
testcase_18 AC 207 ms
159,256 KB
testcase_19 AC 161 ms
130,436 KB
testcase_20 AC 96 ms
76,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

from collections import defaultdict
from itertools import accumulate

def main():
    n = int(input())
    R = list(map(int, input().split()))
    G = list(map(int, input().split()))
    B = list(map(int, input().split()))

    GC = defaultdict(lambda: 0)
    BC = defaultdict(lambda: 0)
    N = 3*10**3
    RC = [0]*(N+1)
    for g in G:
        GC[g] += 1
    for b in B:
        BC[b] += 1
    for r in R:
        RC[r] += 1
    RC = list(accumulate(RC))
    ans = 0
    for g, gc in GC.items():
        for b, bc in BC.items():
            x = min(N+1, max(g, b))
            y = min(N+1, g+b)
            cnt = RC[y-1]-RC[x-1]
            ans += max(0, cnt)*gc*bc
    print(ans)

if __name__ == '__main__':
    main()
0