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语言代码)浏览:767 |
成绩转换 (C语言代码)浏览:1010 |
【绝对值排序】 (C语言代码)浏览:825 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:569 |
核桃的数量 (C语言代码)浏览:672 |
整数平均值 (C语言代码)浏览:787 |
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:585 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:810 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:547 |
字符删除 (C语言代码)浏览:721 |