Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 2 KBi |
#2 |
Correcto
|
0.005 s | 1 KBi |
#3 |
Correcto
|
0.006 s | 2 KBi |
#4 |
Correcto
|
0.005 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 1 KBi |
#6 |
Correcto
|
0.007 s | 22 KBi |
#7 |
Correcto
|
0.008 s | 43 KBi |
#8 |
Correcto
|
0.038 s | 2 KBi |
#9 |
Correcto
|
0.153 s | 15 KBi |
#10 |
Correcto
|
0.143 s | 2 KBi |
#11 |
Correcto
|
0.134 s | 2 KBi |
#12 |
Correcto
|
0.152 s | 1 KBi |
#13 |
Correcto
|
0.152 s | 2 KBi |
#14 |
Correcto
|
0.142 s | 4 KBi |
#include<iostream> using namespace std; int main() { int n; cin >> n; int values[n]; int total[n]; for (int i = 0; i < n; i++) { cin >> values[i]; if (i == 0) { total[i] = values[i]; } else { total[i] = total[i-1] + values[i]; } } int c; cin >> c; int p, q; for (int i = 0; i < c; i++) { cin >> p >> q; int response = 0; if (p == 0) { response = total[q]; } else { response = total[q] - total[p-1]; } cout << response << endl; } return 0; }