1 solutions
-
0
C++ :
#include<bits/stdc++.h> using namespace std; int n,m,A[110000],s[110000],a,b; int main() { // freopen("chicken0.in","r",stdin); // freopen("chicken0.out","w",stdout); scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { scanf("%d",&A[i]); s[i]=s[i-1]+A[i]; } for(int i=1;i<=m;i++) { scanf("%d%d",&a,&b); if(a>b) swap(a,b); printf("%d\n",s[b]-s[a-1]); } return 0; }
Information
- ID
- 1096
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 4
- Tags
- # Submissions
- 39
- Accepted
- 18
- Uploaded By