結果
| 問題 | 
                            No.789 範囲の合計
                             | 
                    
| コンテスト | |
| ユーザー | 
                             pasoconhoshii
                         | 
                    
| 提出日時 | 2019-02-11 22:04:40 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 699 bytes | 
| コンパイル時間 | 85 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 35,712 KB | 
| 最終ジャッジ日時 | 2024-07-19 09:08:11 | 
| 合計ジャッジ時間 | 4,765 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 1 RE * 3 TLE * 1 -- * 10 | 
ソースコード
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
Q = [ list(map(int, input().split())) for _ in range(N)]
from collections import defaultdict
from bisect import bisect_left, bisect_right
pairdic = defaultdict(int)
inf = float("inf")
ans = 0
for q,x,y in Q:
    if q == 0:
        pairdic[x] += y
        idx_cnt = [ (idx, pairdic[idx]) for idx in pairdic.keys()]
        idx_cnt = sorted(idx_cnt)
    if q == 1:
        l,r = x,y
        lidx = bisect_left(  idx_cnt, (l,0))
        ridx = bisect_right(  idx_cnt, (r,inf))
        #print(idx_cnt)
        #print(lidx, ridx)
        ans += sum( list(map(lambda x: x[1], idx_cnt))[lidx:ridx], 0)
        # print("ans: ", ans)
print(ans)
            
            
            
        
            
pasoconhoshii