Skip to content

Instantly share code, notes, and snippets.

@izanbf1803
Last active November 12, 2017 20:28
Show Gist options
  • Save izanbf1803/db7e61a91a21414d8b0a757df68801fc to your computer and use it in GitHub Desktop.
Save izanbf1803/db7e61a91a21414d8b0a757df68801fc to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
using namespace std;
const int _1e5 = 100000;
int abs(int n) { return (n < 0 ? -n : n); }
int main()
{
int n, q, a, b, res;
int bolets[_1e5 + 1];
int cas = 0;
while (cin >> n) {
cas++;
for (int i = 0; i < n; i++) {
cin >> bolets[i];
if (i > 0) bolets[i] += bolets[i - 1];
}
cin >> q;
cout << '#' << cas << endl;
for (int i = 0; i < q; i++) {
cin >> a >> b;
res = bolets[max(a, b) - 1];
if (min(a, b) - 2 >= 0) res -= bolets[min(a, b) - 2];
cout << res << endl;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment