1 solutions

  • 0
    @ 2022-5-27 22:36:59
    #include <bits/stdc++.h>
    using namespace std;
    #define accelerate ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
    #define endl "\n";
    #define mod 12345
    #define ll long long
    #define PII pair<int,int>
    #define INF 0x3f3f3f3f
    const int N=1e5+10;
    ll n,m,k,x,y,T;
    ll a[N];
    ll pre[N];
    int main(){
    	accelerate;
    	cin>>n>>m;
    	for(int i=1;i<=n;i++){
    		cin>>a[i];
    		pre[i]=a[i]+pre[i-1];
    	}
    	while(m--){
    		cin>>x>>y;
    		cout<<pre[y]-pre[x-1]<<endl;
    	}
    	return 0;
    }
    
    • 1

    Information

    ID
    1842
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    1
    Tags
    # Submissions
    94
    Accepted
    56
    Uploaded By