結果
| 問題 |
No.1673 Lamps on a line
|
| コンテスト | |
| ユーザー |
merlin
|
| 提出日時 | 2021-09-10 21:26:13 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 376 ms / 2,000 ms |
| コード長 | 777 bytes |
| コンパイル時間 | 2,848 ms |
| コンパイル使用メモリ | 76,452 KB |
| 実行使用メモリ | 51,672 KB |
| 最終ジャッジ日時 | 2024-06-11 22:24:41 |
| 合計ジャッジ時間 | 6,263 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
ソースコード
import java.io.*;
import java.util.*;
class Main
{
public static void main(String args[])throws Exception
{
BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb=new StringBuilder();
String s[]=bu.readLine().split(" ");
int n=Integer.parseInt(s[0]),q=Integer.parseInt(s[1]);
int ans=0,i;
boolean t[]=new boolean[n];
while(q-->0)
{
s=bu.readLine().split(" ");
int l=Integer.parseInt(s[0])-1,r=Integer.parseInt(s[1])-1;
for(i=l;i<=r;i++)
{
t[i]=!t[i];
if(t[i]) ans++;
else ans--;
}
sb.append(ans+"\n");
}
System.out.print(sb);
}
}
merlin