Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 4 KBi |
#2 |
Correcto
|
0.004 s | 1 KBi |
#3 |
Correcto
|
0.006 s | 2 KBi |
#4 |
Correcto
|
0.008 s | 3 KBi |
#5 |
Correcto
|
0.006 s | 3 KBi |
#6 |
Correcto
|
0.004 s | 1 KBi |
#7 |
Correcto
|
0.003 s | 1 KBi |
#8 |
Correcto
|
0.03 s | 1 KBi |
#9 |
Correcto
|
0.227 s | 2 KBi |
#10 |
Correcto
|
0.158 s | 2 KBi |
#11 |
Correcto
|
0.131 s | 2 KBi |
#12 |
Correcto
|
0.138 s | 2 KBi |
#13 |
Correcto
|
0.163 s | 5 KBi |
#14 |
Correcto
|
0.178 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; }