Submission
Id | When | Author | Problem | Language | CPU | Memory | Verdict |
---|---|---|---|---|---|---|---|
17831 | 2024-04-24 00:27:55 | SajidAbdullah | Help Akib!!! | C++ 17 | 503 ms | 6128 kb | Accepted |
Test Cases
CPU | Memory | Verdict | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 ms | 3380 kb | Accepted | ||||||||
2 | 1 ms | 3324 kb | Accepted | ||||||||
3 | 255 ms | 4704 kb | Accepted | ||||||||
4 | 503 ms | 6128 kb | Accepted | ||||||||
5 | 404 ms | 5500 kb | Accepted | ||||||||
6 | 4 ms | 3276 kb | Accepted | ||||||||
Source Code
program.cpp
#include<bits/stdc++.h> #define endl "\n" #define FF ios_base::sync_with_stdio(0);cin.tie(0) #define binary(value, size) cout << bitset<size>(value) << '\n' #define Tp template<class T> #define Tpp template<typename T> #define Tppp template<typename T1,typename T2> #define eps 1e-9 #define pf printf #define sf scanf #define clr(arr,val) memset((arr),val,(sizeof(arr))) #define rep(i,a,b) for(long long int i=a;i<b;i++) #define repb(i,a,b) for(long long int i=a;i>=b;i--) #define all(v) (v).begin(),(v).end() #define asort(a) sort(a.begin(),a.end()) #define arev(a) reverse(a.begin(),a.end()) #define F first #define S second #define pb push_back #define eb emplace_back #define pbb pop_back #define mp make_pair #define V vector #define P pair #define M map #define mt make_tuple #define BS(v,x) binary_search(v.begin(),v.end(),x) //return true /false #define LB(v,x) lower_bound(v.begin(),v.end(),x)-v.begin()//found and that value and not found than greater value pos #define UB(v,x) upper_bound(v.begin(),v.end(),x)-v.begin() //found and greater value pos && not found also greater pos #define sma(c) towlower(c) #define rt(x) sqrt(x) #define cap(c) towupper(c) #define sq(a) ((a)*(a)) #define cube(a) ((a)*(a)*(a)) #define SUM(v) accumulate (v.begin(),v.end(),0)//sum of the vector #define MAX(v) *max_element(v.begin(),v.end())//max element of the vector #define MIN(v) *min_element(v.begin(),v.end())//min element of the vector #define SZ(x) long long int(x.size()) #define Ceil(n) (long long int)ceil(n) #define Floor(n) (long long int)floor(n) #define deb(x) cout << #x << " = " << x << "\n"; #define deb2(x,y) cout << #x << " = " << x << ", "; cout << #y << " = " << y << "\n"; #define deb3(x,y,z) cout << #x << " = " << x << ", "; cout << #y << " = " << y << ", "; cout << #z << " = " << z << "\n"; #define deb4(x,y,z,r) cout << #x << " = " << x << ", "; cout << #y << " = " << y << ", "; cout << #z << " = " << z << ", ";cout << #r << " = " << r << "\n"; #define out(ans) cout<<ans<<"\n" #define mx 1000000 #define outs(ans) cout<<ans<<" "<<"\n" #define FI freopen ("in.txt", "r", stdin) #define FO freopen ("out.txt", "w", stdout) using namespace std; typedef long long int ll; typedef pair<ll,ll> pll; typedef vector<ll> vll; typedef vector<pll> vpll; class PrefixSum { private: vll pref; ll ss; public: PrefixSum(vector<ll>const &arr) { ll n=arr.size(); pref.resize(n,0); ss=0; for(ll i=0;i<n;i++) { ss+=arr[i]; pref[i]=ss; } } vll get() { return pref; } ll query(ll left, ll right) { if(left>right) return -1e18; if(left>0) { return (pref[right]-pref[left-1]); } else return pref[right]; } }; const ll RR=1e9-1; void S() { ll n,q;cin>>n>>q; vll v(n); rep(i,0,n) { cin>>v[i]; } PrefixSum sp(v); rep(i,0,q) { ll x1,y1;cin>>x1>>y1; x1--;y1--; ll val=sp.query(x1,y1); cout<<val<<endl; } } int main() { //Go(); S(); return 0; }