import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader sc=new BufferedReader(new InputStreamReader(System.in)); PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out)); String[]nums=sc.readLine().split(" "); int n=Integer.parseInt(nums[0]); int m=Integer.parseInt(nums[1]); long[]a=new long[n+1]; String[]s=sc.readLine().split(" "); for (int i = 0; i <s.length; i++) { a[i+1]=a[i]+Integer.parseInt(s[i]); } for (int i = 0; i < m; i++) { nums=sc.readLine().split(" "); int first=Integer.parseInt(nums[0]); int end=Integer.parseInt(nums[1]); out.println(a[end]-a[first-1]); out.flush(); } } }
0.0分
1 人评分
【数组的距离】 (C语言代码)浏览:608 |
C语言程序设计教程(第三版)课后习题11.3 (C语言代码)浏览:900 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:674 |
C语言程序设计教程(第三版)课后习题5.8 (C语言代码)浏览:943 |
P1001 (C语言代码)浏览:801 |
蛇行矩阵 (C语言代码)浏览:753 |
2006年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:647 |
文科生的悲哀 (C语言代码)浏览:1401 |
1071题解浏览:493 |
理财计划 (C语言代码)浏览:467 |