感谢y老师和徐老师❤️
第一次不是照着题解敲的算法基础课
希望我早日变强 offer多多多多多多多多多多多多
import java.util.*;
public class Main{
private static int N = 10010;
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int m = scan.nextInt();
int n = scan.nextInt();
int[] a = new int[m];
for(int i = 1; i <= m; i++) a[i] = scan.nextInt();
int[] s = new int[N];
s[0] = 0
for(int i = 1; i <= m ; i++) s[i] = s[i - 1] + a[i];
while(n -- > 0){
int l = scan.nextInt();
int r = scan.nextInt();
System.out.println(s[r] - s[l - 1]);
}
}
}