Submit Info #66516

Problem Lang User Status Time Memory
Static Range Sum cpp samp123 AC 162 ms 11.67 MiB

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.45 MiB
max_random_00 AC 140 ms 11.67 MiB
max_random_01 AC 142 ms 11.66 MiB
max_random_02 AC 153 ms 11.66 MiB
max_random_03 AC 160 ms 11.61 MiB
max_random_04 AC 162 ms 11.67 MiB
random_00 AC 116 ms 9.36 MiB
random_01 AC 130 ms 10.08 MiB
random_02 AC 74 ms 6.17 MiB
random_03 AC 39 ms 4.52 MiB
random_04 AC 42 ms 4.52 MiB

#include "bits/stdc++.h" using namespace std; typedef long long int ll; typedef vector<int> vi; typedef vector<long long> vll; typedef pair<int,int> pii; int main() { ios_base::sync_with_stdio(false); cin.tie(0); #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int T; T=1; while(T--){ int n,q; cin>>n>>q; vector<ll>sums; int val; ll cur_sum=0; for(int i=0;i<n;i++){ cin>>val; cur_sum+=val; sums.push_back(cur_sum); } // cout<<q<<'\n'; int l,r; while(q--){ cin>>l>>r; if(l-1<0) cout<<sums[r-1]<<'\n'; else cout<<sums[r-1]-sums[l-1]<<'\n'; } } return 0; }