Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main() {
- vector<int>v;
- int n,m,x,ini,fin,resp=0;
- cin>>n>>m;
- for (int i=0;i<n;i++){
- cin>>x;
- v.push_back(x);
- }
- for (int i=0;i<m;i++){
- cin>>ini>>fin;
- int aux=0;
- for (int j=ini-1;j<fin;j++){
- aux+=v[j];
- }
- if (aux>0)
- resp+=aux;
- }
- cout<<resp<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement