結果

問題 No.1673 Lamps on a line
ユーザー ripityripity
提出日時 2021-10-23 20:41:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,339 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 2,324 ms
コンパイル使用メモリ 74,744 KB
実行使用メモリ 82,036 KB
最終ジャッジ日時 2023-10-26 04:02:30
合計ジャッジ時間 13,842 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
57,532 KB
testcase_01 AC 131 ms
57,452 KB
testcase_02 AC 789 ms
72,504 KB
testcase_03 AC 776 ms
72,448 KB
testcase_04 AC 1,095 ms
73,028 KB
testcase_05 AC 317 ms
61,408 KB
testcase_06 AC 994 ms
72,668 KB
testcase_07 AC 934 ms
74,408 KB
testcase_08 AC 229 ms
60,184 KB
testcase_09 AC 1,160 ms
72,772 KB
testcase_10 AC 1,208 ms
72,976 KB
testcase_11 AC 401 ms
62,396 KB
testcase_12 AC 1,339 ms
82,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
        
    }
    
}
0