Submit Info #66202

Problem Lang User Status Time Memory
Static Range Sum cpp14 (anonymous) AC 648 ms 15.33 MiB

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.45 MiB
max_random_00 AC 630 ms 15.32 MiB
max_random_01 AC 648 ms 15.32 MiB
max_random_02 AC 632 ms 15.32 MiB
max_random_03 AC 637 ms 15.29 MiB
max_random_04 AC 641 ms 15.33 MiB
random_00 AC 511 ms 12.27 MiB
random_01 AC 541 ms 13.38 MiB
random_02 AC 377 ms 6.32 MiB
random_03 AC 140 ms 7.32 MiB
random_04 AC 174 ms 6.00 MiB

#include<bits/stdc++.h> using namespace std; typedef long long int ll; #define pb push_back const int maxn=1e6; int main() { ll n,q;cin>>n>>q; ll ar[n+1]; ll dp[n+1]; for(int i=0;i<n;i++) { cin>>ar[i]; if(i==0) dp[i]=ar[i]; else dp[i]=ar[i]+dp[i-1]; } while(q--) { int x,y;cin>>x>>y; if(x==0) { cout<<dp[y-1]<<'\n'; } else cout<<dp[y-1]-dp[x-1]<<'\n'; } }