Submit Info #67218

Problem Lang User Status Time Memory
Static Range Sum java (anonymous) AC 2104 ms 99.90 MiB

ケース詳細
Name Status Time Memory
example_00 AC 86 ms 11.13 MiB
max_random_00 AC 2064 ms 99.88 MiB
max_random_01 AC 2068 ms 99.87 MiB
max_random_02 AC 2074 ms 99.84 MiB
max_random_03 AC 2077 ms 99.90 MiB
max_random_04 AC 2104 ms 99.86 MiB
random_00 AC 1782 ms 96.83 MiB
random_01 AC 1856 ms 98.05 MiB
random_02 AC 1464 ms 91.03 MiB
random_03 AC 757 ms 90.20 MiB
random_04 AC 885 ms 90.52 MiB

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int q = sc.nextInt(); int[] arr = new int[n]; for (int x = 0; x < n; x++) { arr[x] = sc.nextInt(); } long[] sums = new long[n + 1]; for (int x = 0; x < n; x++) { sums[x + 1] = sums[x] + arr[x]; } for (int x = 0; x < q; x++) { int l = sc.nextInt(); int r = sc.nextInt(); System.out.println(sums[r] - sums[l]); } } }