結果

問題 No.1441 MErGe
ユーザー tenten
提出日時 2021-03-30 12:05:28
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 895 bytes
コンパイル時間 3,113 ms
コンパイル使用メモリ 85,864 KB
実行使用メモリ 155,016 KB
最終ジャッジ日時 2024-11-30 09:16:20
合計ジャッジ時間 48,422 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 8 TLE * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        long base = 0;
        ArrayList<Long> list = new ArrayList<>();
        list.add(base);
        for (int i = 0; i < n; i++) {
            base += sc.nextInt();
            list.add(base);
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++) {
            int type = sc.nextInt();
            int left = sc.nextInt();
            int right = sc.nextInt();
            if (type == 1) {
                for (int j = left; j < right; j++) {
                    list.remove(left);
                }
            } else {
                sb.append(list.get(right) - list.get(left - 1)).append("\n");
            }
        }
        System.out.print(sb);
    }
}
0