結果
問題 |
No.1623 三角形の制作
|
ユーザー |
![]() |
提出日時 | 2023-05-10 09:25:12 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 815 bytes |
コンパイル時間 | 143 ms |
コンパイル使用メモリ | 81,864 KB |
実行使用メモリ | 171,028 KB |
最終ジャッジ日時 | 2024-11-26 13:56:47 |
合計ジャッジ時間 | 32,517 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 TLE * 10 |
ソースコード
# max(g,b) <= r < g+b from bisect import bisect_left as bl , bisect_right as br from collections import Counter n = int(input()) r = list(map(int,input().split())) g = list(map(int,input().split())) b = list(map(int,input().split())) rs=sorted(tuple(Counter(r).items())) gs=sorted(tuple(Counter(g).items())) bs=sorted(tuple(Counter(b).items())) rcnt = [0] for i in range(len(rs)): rcnt.append(rcnt[-1]+rs[i][1]) rk = [0]+[i for i,j in rs] ans=0 for i in range(len(gs)): for j in range(len(bs)): y=gs[i][0]+bs[j][0] x=max(gs[i][0],bs[j][0]) if x >= y: continue xind,yind=bl(rk,x),bl(rk,y) xind=max(xind-1,0) yind=max(yind-1,0) t1=rcnt[yind]-rcnt[xind] ans += t1*gs[i][1]*bs[j][1] print(ans)