結果
| 問題 |
No.1673 Lamps on a line
|
| コンテスト | |
| ユーザー |
ripity
|
| 提出日時 | 2021-10-23 20:41:18 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 1,223 ms / 2,000 ms |
| コード長 | 620 bytes |
| コンパイル時間 | 1,971 ms |
| コンパイル使用メモリ | 78,792 KB |
| 実行使用メモリ | 66,464 KB |
| 最終ジャッジ日時 | 2024-09-25 11:53:26 |
| 合計ジャッジ時間 | 12,362 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] cnt = new int[N];
int Q = sc.nextInt();
int ans = 0;
for( int i = 0; i < Q; i++ ) {
int L = sc.nextInt()-1;
int R = sc.nextInt()-1;
for( int j = L; j <= R; j++ ) {
cnt[j]++;
if( cnt[j]%2 == 0 ) ans--;
else ans++;
}
System.out.println(ans);
}
sc.close();
}
}
ripity