結果
問題 | No.1673 Lamps on a line |
ユーザー | harurun |
提出日時 | 2021-09-10 22:29:07 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 163 ms / 2,000 ms |
コード長 | 1,596 bytes |
コンパイル時間 | 288 ms |
コンパイル使用メモリ | 86,868 KB |
実行使用メモリ | 106,288 KB |
最終ジャッジ日時 | 2023-09-02 18:49:39 |
合計ジャッジ時間 | 2,959 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
71,364 KB |
testcase_01 | AC | 73 ms
71,272 KB |
testcase_02 | AC | 136 ms
88,416 KB |
testcase_03 | AC | 135 ms
88,444 KB |
testcase_04 | AC | 163 ms
95,988 KB |
testcase_05 | AC | 111 ms
78,088 KB |
testcase_06 | AC | 150 ms
93,456 KB |
testcase_07 | AC | 129 ms
93,724 KB |
testcase_08 | AC | 85 ms
78,892 KB |
testcase_09 | AC | 142 ms
99,052 KB |
testcase_10 | AC | 156 ms
100,872 KB |
testcase_11 | AC | 96 ms
80,012 KB |
testcase_12 | AC | 152 ms
106,288 KB |
ソースコード
class INPUT: def __init__(self): self._l=open(0).read().split() self._length=len(self._l) self._index=0 return def stream(self,k=1,f=int,f2=False): assert(-1<k) if self._length==self._index or self._length-self._index<k: raise Exception("There is no input!") elif f!=str: if k==0: ret=list(map(f,self._l[self._index:])) self._index=self._length return ret if k==1 and not f2: ret=f(self._l[self._index]) self._index+=1 return ret if k==1 and f2: ret=[f(self._l[self._index])] self._index+=1 return ret ret=[] for _ in [0]*k: ret.append(f(self._l[self._index])) self._index+=1 return ret else: if k==0: ret=list(self._l[self._index:]) self._index=self._length return ret if k==1 and not f2: ret=self._l[self._index] self._index+=1 return ret if k==1 and f2: ret=[self._l[self._index]] self._index+=1 return ret ret=[] for _ in [0]*k: ret.append(self._l[self._index]) self._index+=1 return ret pin=INPUT().stream #pin(number[default:1],f[default:int],f2[default:False]) #if number==0 -> return left all #listを変数で受け取るとき、必ずlistをTrueにすること。 def main(): N,Q=pin(2) cnt=0 d=[0]*N for i in range(Q): L,R=pin(2) for j in range(L-1,R): if d[j]==0: cnt+=1 d[j]=1 else: cnt-=1 d[j]=0 print(cnt) return main()