結果
問題 | No.1014 competitive fighting |
ユーザー | mkawa2 |
提出日時 | 2020-03-24 12:06:03 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,039 bytes |
コンパイル時間 | 110 ms |
コンパイル使用メモリ | 11,280 KB |
実行使用メモリ | 39,612 KB |
最終ジャッジ日時 | 2023-08-30 05:18:38 |
合計ジャッジ時間 | 15,207 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 18 ms
8,644 KB |
testcase_01 | AC | 18 ms
8,504 KB |
testcase_02 | AC | 17 ms
8,624 KB |
testcase_03 | AC | 18 ms
8,508 KB |
testcase_04 | AC | 18 ms
8,728 KB |
testcase_05 | AC | 1,932 ms
34,652 KB |
testcase_06 | AC | 1,933 ms
34,532 KB |
testcase_07 | AC | 1,940 ms
34,500 KB |
testcase_08 | AC | 1,938 ms
34,704 KB |
testcase_09 | AC | 1,938 ms
34,632 KB |
testcase_10 | TLE | - |
testcase_11 | AC | 962 ms
35,756 KB |
testcase_12 | AC | 1,956 ms
34,728 KB |
testcase_13 | AC | 861 ms
20,816 KB |
testcase_14 | AC | 790 ms
19,976 KB |
testcase_15 | AC | 949 ms
22,016 KB |
testcase_16 | AC | 42 ms
9,256 KB |
testcase_17 | AC | 316 ms
13,672 KB |
testcase_18 | AC | 1,582 ms
30,112 KB |
testcase_19 | AC | 1,886 ms
33,904 KB |
testcase_20 | AC | 616 ms
17,832 KB |
testcase_21 | AC | 1,422 ms
28,240 KB |
testcase_22 | AC | 1,144 ms
24,224 KB |
testcase_23 | AC | 412 ms
14,888 KB |
testcase_24 | AC | 426 ms
15,240 KB |
testcase_25 | AC | 102 ms
10,316 KB |
testcase_26 | AC | 1,398 ms
28,096 KB |
testcase_27 | AC | 313 ms
13,612 KB |
testcase_28 | AC | 351 ms
14,020 KB |
testcase_29 | AC | 28 ms
8,744 KB |
testcase_30 | AC | 1,875 ms
33,884 KB |
testcase_31 | AC | 1,470 ms
28,832 KB |
testcase_32 | AC | 26 ms
8,804 KB |
testcase_33 | AC | 69 ms
10,084 KB |
testcase_34 | AC | 811 ms
28,788 KB |
testcase_35 | AC | 1,081 ms
35,028 KB |
testcase_36 | AC | 731 ms
26,988 KB |
testcase_37 | AC | 36 ms
9,264 KB |
testcase_38 | AC | 645 ms
24,884 KB |
testcase_39 | AC | 320 ms
16,936 KB |
testcase_40 | AC | 630 ms
24,472 KB |
testcase_41 | AC | 446 ms
20,120 KB |
testcase_42 | AC | 1,048 ms
33,864 KB |
testcase_43 | AC | 61 ms
10,028 KB |
testcase_44 | AC | 944 ms
31,708 KB |
testcase_45 | AC | 545 ms
22,276 KB |
testcase_46 | AC | 96 ms
11,192 KB |
testcase_47 | AC | 291 ms
16,244 KB |
testcase_48 | AC | 772 ms
28,064 KB |
testcase_49 | AC | 41 ms
9,308 KB |
testcase_50 | AC | 995 ms
33,040 KB |
testcase_51 | AC | 550 ms
22,600 KB |
testcase_52 | AC | 43 ms
9,640 KB |
testcase_53 | AC | 1,935 ms
34,572 KB |
ソースコード
import sys from bisect import bisect_right from heapq import * sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def SI(): return sys.stdin.readline()[:-1] class SegtreeMax(): def __init__(self, n): self.inf = 10 ** 16 tree_width = 2 while tree_width < n: tree_width *= 2 self.tree_width = tree_width self.tree = [0] * (tree_width * 2 - 1) def update(self, i, a): seg_i = self.tree_width - 1 + i self.tree[seg_i] = a while seg_i != 0: seg_i = (seg_i - 1) // 2 self.tree[seg_i] = max(self.tree[seg_i * 2 + 1], self.tree[seg_i * 2 + 2]) def element(self, i): return self.tree[self.tree_width - 1 + i] def max(self, l, r, seg_i=0, segL=0, segR=-1): if segR == -1: segR = self.tree_width if r <= segL or segR <= l: return 0 if l <= segL and segR <= r: return self.tree[seg_i] segM = (segL + segR) // 2 ret0 = self.max(l, r, seg_i * 2 + 1, segL, segM) ret1 = self.max(l, r, seg_i * 2 + 2, segM, segR) return max(ret0, ret1) def main(): inf=10**15 n=II() abci=[] for i in range(n): a,b,c=MI() abci.append((a,b,c,i)) # aの小さいほうから見ていく # b-cが自分のaより小さければ、遷移先が出そろっているということなので # 遷移先の最大スコアにbを足して自分のスコアにする # スコアはセグメント木に入れておく # b-cがa以上であれば、b-c以下のaが出揃うまでhpに入れて保留する # 保留中はスコアをinfとしてセグメント木にいれておく # 保留中に自分への遷移があったときは、ループができるから abci.sort() ans=[0]*n st=SegtreeMax(n) hp=[] for j,(a,b,c,i) in enumerate(abci): # 保留中から出せるものを処理 while hp and hp[0][0]<a: _,pb,pj=heappop(hp) st.update(pj,0) mx=st.max(0,j) if mx!=inf:mx+=pb st.update(pj,mx) ans[abci[pj][3]]=mx # すぐに処理できるもの if b-c<a: k=bisect_right(abci,(b-c,inf,0,0)) mx=st.max(0,k) if mx!=inf:mx+=b st.update(j,mx) ans[i]=mx # 保留するもの else: st.update(j,inf) heappush(hp,(b-c,b,j)) # 最後まで保留されたものの処理 while hp: _, pb, pj = heappop(hp) st.update(pj,0) mx=st.max(0,n) if mx!=inf:mx+=pb st.update(pj,mx) ans[abci[pj][3]]=mx # 答えの出力 for x in ans: if x==inf:print("BAN") else:print(x) main()