Submit Info #66201

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

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.42 MiB
max_random_00 AC 680 ms 15.32 MiB
max_random_01 AC 664 ms 15.32 MiB
max_random_02 AC 659 ms 15.32 MiB
max_random_03 AC 643 ms 15.32 MiB
max_random_04 AC 663 ms 15.32 MiB
random_00 AC 530 ms 12.27 MiB
random_01 AC 553 ms 13.45 MiB
random_02 AC 387 ms 6.32 MiB
random_03 AC 142 ms 7.25 MiB
random_04 AC 173 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'; } }