結果

問題 No.1673 Lamps on a line
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-07-07 06:05:22
言語 Ruby
(3.3.0)
結果
AC  
実行時間 388 ms / 2,000 ms
コード長 205 bytes
コンパイル時間 572 ms
コンパイル使用メモリ 11,184 KB
実行使用メモリ 19,116 KB
最終ジャッジ日時 2023-09-28 06:25:28
合計ジャッジ時間 5,579 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
15,296 KB
testcase_01 AC 71 ms
15,120 KB
testcase_02 AC 181 ms
15,264 KB
testcase_03 AC 178 ms
15,128 KB
testcase_04 AC 267 ms
15,404 KB
testcase_05 AC 87 ms
15,236 KB
testcase_06 AC 256 ms
15,336 KB
testcase_07 AC 249 ms
18,352 KB
testcase_08 AC 76 ms
17,128 KB
testcase_09 AC 332 ms
15,724 KB
testcase_10 AC 319 ms
17,096 KB
testcase_11 AC 97 ms
17,396 KB
testcase_12 AC 388 ms
19,116 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,m=gets.split(" ").map{|e| e.to_i}
ds=[0]*(n+1)
ans=0
m.times{
	l,r=gets.split(" ").map{|e| e.to_i}
	l.upto(r){|i|
		if ds[i]==0 then
			ans+=1
			ds[i]=1
		else
			ans-=1
			ds[i]=0
		end
	}
	puts ans
}
0