Submit Info #66508

Problem Lang User Status Time Memory
Static Range Sum cpp noobgamer69 AC 160 ms 13.44 MiB

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.45 MiB
max_random_00 AC 146 ms 13.44 MiB
max_random_01 AC 143 ms 13.44 MiB
max_random_02 AC 160 ms 13.36 MiB
max_random_03 AC 144 ms 13.44 MiB
max_random_04 AC 148 ms 13.44 MiB
random_00 AC 119 ms 10.80 MiB
random_01 AC 123 ms 11.65 MiB
random_02 AC 77 ms 6.20 MiB
random_03 AC 39 ms 5.63 MiB
random_04 AC 45 ms 4.92 MiB

#include "bits/stdc++.h" using namespace std; #define ll long long #define ld long double #define endl '\n' #define debug cout<<"debug"<<endl; const ll MOD = 1e9 + 7; void printArr(int arr[], int n,string s="\n"){ if(s==" "){ for(int i=0;i<n;i++){ cout<<arr[i]<<" "; } cout<<endl; } else{ for(int i=0;i<n;i++){ cout<<arr[i]<<'\n'; } } } void inputArr(int arr[],int n){ for(int i=1;i<=n;i++){ cin>>arr[i]; } } void inputVector(vector<int>v,int n){ for(int i=0;i<n;i++){ int x; cin>>x; v.push_back(x); } } int min(int a, int b){ if(a>b) return b; return a; } int max(int a, int b){ if(a>b) return a; return b; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int n,q; cin>>n>>q; int arr[n]; ll sumArr[n+1]; ll sum = 0; sumArr[0] = 0; for(int i =0;i<n;i++){ cin>>arr[i]; sum+= arr[i]; sumArr[i+1] = sum; } for(int i = 0;i<q;i++){ int l , r ; cin>>l>>r; cout<<sumArr[r] - sumArr[l]<<endl; } return 0; }