結果

問題 No.59 鉄道の旅
ユーザー pluto77pluto77
提出日時 2016-07-10 13:28:09
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 444 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 6,644 KB
実行使用メモリ 7,696 KB
最終ジャッジ日時 2023-08-26 07:03:44
合計ジャッジ時間 1,906 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
7,580 KB
testcase_01 AC 22 ms
7,508 KB
testcase_02 AC 22 ms
7,464 KB
testcase_03 AC 22 ms
7,580 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 41 ms
7,540 KB
testcase_12 AC 193 ms
7,636 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#coding: utf-8
#yuki_059

n,k=map(int,raw_input().split())
bit=[0 for i in xrange(100001)]
cnt=[0 for i in xrange(100001)]

def sum(i):
 s=0
 while i>0:
  s+=bit[i]
  i-=i & (-i)
 return s
 
def add(i,x):
 while i<=100000:
  bit[i]+=x
  i+=i & (-i)
  
total=0
for i in xrange(n):
 w=int(raw_input())
 if w>0:
  if total-sum(w-1)<k:
   add(w,1)
   cnt[w]+=1
   total+=1
 else:
  if cnt[-w]>0:
   add(-w,-1)
   cnt[-w]-=1
   total-=1
print total
0