結果
問題 | No.1441 MErGe |
ユーザー | tenten |
提出日時 | 2022-09-02 11:57:40 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,704 bytes |
コンパイル時間 | 2,097 ms |
コンパイル使用メモリ | 78,332 KB |
実行使用メモリ | 97,632 KB |
最終ジャッジ日時 | 2024-04-27 14:39:25 |
合計ジャッジ時間 | 29,352 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 49 ms
50,072 KB |
testcase_01 | AC | 49 ms
50,060 KB |
testcase_02 | AC | 49 ms
50,332 KB |
testcase_03 | AC | 108 ms
52,324 KB |
testcase_04 | AC | 121 ms
52,184 KB |
testcase_05 | AC | 151 ms
55,744 KB |
testcase_06 | AC | 151 ms
55,712 KB |
testcase_07 | AC | 152 ms
54,720 KB |
testcase_08 | AC | 428 ms
59,664 KB |
testcase_09 | AC | 409 ms
60,356 KB |
testcase_10 | AC | 469 ms
60,948 KB |
testcase_11 | AC | 438 ms
60,904 KB |
testcase_12 | AC | 482 ms
61,064 KB |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | AC | 920 ms
67,800 KB |
testcase_21 | AC | 948 ms
67,788 KB |
testcase_22 | AC | 873 ms
68,152 KB |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | TLE | - |
testcase_26 | TLE | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
ソースコード
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int q = sc.nextInt(); long[] sums = new long[n + 1]; ArrayList<Integer> idxes = new ArrayList<>(); idxes.add(0); for (int i = 1; i <= n; i++) { sums[i] = sums[i - 1] + sc.nextInt(); idxes.add(i); } StringBuilder sb = new StringBuilder(); while (q-- > 0) { int type = sc.nextInt(); int left = sc.nextInt(); int right = sc.nextInt(); if (type == 1) { for (int i = 0; i < right - left; i++) { idxes.remove(left); } } else { sb.append(sums[idxes.get(right)] - sums[idxes.get(left - 1)]).append("\n"); } } System.out.print(sb); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }