結果

問題 No.1623 三角形の制作
ユーザー lloyzlloyz
提出日時 2021-12-08 22:08:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 373 ms / 2,000 ms
コード長 818 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 135,060 KB
最終ジャッジ日時 2023-09-23 10:27:51
合計ジャッジ時間 6,759 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
77,032 KB
testcase_01 AC 107 ms
76,988 KB
testcase_02 AC 334 ms
119,964 KB
testcase_03 AC 322 ms
122,684 KB
testcase_04 AC 320 ms
122,692 KB
testcase_05 AC 373 ms
132,588 KB
testcase_06 AC 273 ms
84,492 KB
testcase_07 AC 322 ms
123,040 KB
testcase_08 AC 279 ms
86,788 KB
testcase_09 AC 314 ms
117,196 KB
testcase_10 AC 341 ms
123,488 KB
testcase_11 AC 330 ms
121,612 KB
testcase_12 AC 146 ms
103,124 KB
testcase_13 AC 151 ms
111,556 KB
testcase_14 AC 147 ms
107,488 KB
testcase_15 AC 211 ms
135,056 KB
testcase_16 AC 207 ms
135,020 KB
testcase_17 AC 209 ms
135,060 KB
testcase_18 AC 222 ms
133,420 KB
testcase_19 AC 173 ms
130,580 KB
testcase_20 AC 106 ms
77,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heappush
from collections import defaultdict

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

R_len_cnt = [0 for _ in range(3001)]
G_len_cnt = [0 for _ in range(3001)]
B_len_cnt = [0 for _ in range(3001)]
for i in range(n):
    R_len_cnt[R[i]] += 1
    G_len_cnt[G[i]] += 1
    B_len_cnt[B[i]] += 1
accumR_len_cnt = [0 for _ in range(3001)]
for i in range(3000):
    accumR_len_cnt[i + 1] += accumR_len_cnt[i] + R_len_cnt[i + 1]
ans = 0
for i in range(1, 3001):
    if G_len_cnt[i] == 0:
        continue
    for j in range(1, 3001):
        if B_len_cnt[j] == 0:
            continue
        ans += G_len_cnt[i] * B_len_cnt[j] * (accumR_len_cnt[min(i + j, 3001) - 1] - accumR_len_cnt[max(i, j) - 1])
print(ans)

0