Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 1 KBi |
#2 |
Correcto
|
0.005 s | 1 KBi |
#3 |
Correcto
|
0.004 s | 1 KBi |
#4 |
Correcto
|
0.005 s | 1 KBi |
#5 |
Correcto
|
0.004 s | 1 KBi |
#6 |
Correcto
|
0.005 s | 9 KBi |
#7 |
Correcto
|
0.006 s | 1 KBi |
#8 |
Correcto
|
0.038 s | 1 KBi |
#9 |
Correcto
|
0.157 s | 2 KBi |
#10 |
Correcto
|
0.157 s | 2 KBi |
#11 |
Correcto
|
0.151 s | 2 KBi |
#12 |
Correcto
|
0.14 s | 1 KBi |
#13 |
Correcto
|
0.163 s | 1 KBi |
#14 |
Correcto
|
0.159 s | 2 KBi |
#include <iostream> #include <vector> #include <cassert> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } assert(n > 0); vector<int> sum(n); for (int i = 0; i < n; ++i) { sum[i] = a[i]; if (i - 1 >= 0) sum[i] += sum[i - 1]; } int c; cin >> c; while (c--) { int p, q; cin >> p >> q; int answer = sum[q]; if (p - 1 >= 0) { answer -= sum[p - 1]; } cout << answer << endl; } return 0; }