Submit Info #68783

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

ケース詳細
Name Status Time Memory
example_00 AC 86 ms 11.11 MiB
max_random_00 AC 2013 ms 111.30 MiB
max_random_01 AC 2076 ms 111.36 MiB
max_random_02 AC 2044 ms 111.39 MiB
max_random_03 AC 2047 ms 111.39 MiB
max_random_04 AC 2079 ms 111.43 MiB
random_00 AC 1747 ms 106.08 MiB
random_01 AC 1804 ms 108.33 MiB
random_02 AC 1454 ms 96.69 MiB
random_03 AC 756 ms 98.44 MiB
random_04 AC 884 ms 95.61 MiB

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int i = in.nextInt(); int n = in.nextInt(); long[] nums = new long[i]; long[] prefix = new long[i+1]; for(int j = 0; j<i; j++) { nums[j] = in.nextInt(); } for(int k = 1; k<i+1; k++) { prefix[k] = prefix[k-1] + nums[k-1]; } int a = 0; int b = 0; long[] ans = new long[n]; for(int l = 0; l<n; l++) { a = in.nextInt(); b = in.nextInt(); ans[l] = prefix[b]-prefix[a]; } for(int m = 0; m<ans.length; m++) { System.out.println(ans[m]); } } }