Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
31705 | zhangchunhong | 区间求和 | C++ | Accepted | 0 MS | 256 KB | 295 | 2023-11-21 21:17:11 |
#include<iostream> using namespace std; int a[100010]; int main() { int n,m,sum=0; cin>>n>>m; for(int i=1;i<=n;i++){ cin>>a[i]; } while(m--){ //O(m*n) 10^10 int l,r; cin>>l>>r; sum=0; for(int i=l;i<=r;i++){ sum+=a[i]; } cout<<sum<<endl; } return 0; }