Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
31711 | zhangchunhong | 区间求和 | C++ | Accepted | 0 MS | 256 KB | 308 | 2023-11-21 21:21:00 |
#include<iostream> using namespace std; int a[100010]; int main() { int n,m,sum=0; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); } while(m--){ int l,r; scanf("%d%d",&l,&r); sum=0; for(int i=l;i<=r;i++){ sum+=a[i]; } cout<<sum<<endl; } return 0; }