-
-
Save ArthurLoboLobo/c738db1d46967a8845688fafedc42dee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
int n, q, sk; | |
long long d[110000], p[110000]; | |
int main() { | |
cin >> n; | |
sk = 0; | |
for(int i = 1; i <= n; i++) { | |
int k,p; | |
cin >> k >> p; | |
for(int j = sk+1; j <= sk+k; j++) { | |
d[j] = p; | |
} | |
sk+= k; | |
} | |
p[0] = 0; | |
for(int i = 1; i <= sk; i++) { | |
p[i] = p[i-1]+d[i]; | |
} | |
cin >> q; | |
for(int i = 1; i <= q; i++) { | |
int x,y; | |
cin >> x >> y; | |
cout << p[y]-p[x-1] << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment