Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 1 KBi |
#2 |
Correcto
|
0.004 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.004 s | 1 KBi |
#5 |
Correcto
|
0.006 s | 3 KBi |
#6 |
Correcto
|
0.005 s | 1 KBi |
#7 |
Correcto
|
0.005 s | 1 KBi |
#8 |
Correcto
|
0.028 s | 1 KBi |
#9 |
Correcto
|
0.208 s | 2 KBi |
#10 |
Correcto
|
0.133 s | 1 KBi |
#11 |
Correcto
|
0.124 s | 2 KBi |
#12 |
Correcto
|
0.225 s | 2 KBi |
#13 |
Correcto
|
0.193 s | 2 KBi |
#14 |
Correcto
|
0.217 s | 2 KBi |
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n); vector<int> sum(n); int total = 0; for (long i = 0; i < n; i++) { cin >> a[i]; total += a[i]; sum[i] = total; } int c, p,q, res; cin >> c; for (int i = 0; i < c; i++) { cin >> p; cin >> q; res = sum[q]; if (p-1 >= 0) { res -= sum[p-1]; } cout << res << endl; } return 0; }