Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 1 KBi |
#2 |
Correcto
|
0.005 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.006 s | 1 KBi |
#5 |
Correcto
|
0.006 s | 61 KBi |
#6 |
Correcto
|
0.005 s | 1 KBi |
#7 |
Correcto
|
0.006 s | 1 KBi |
#8 |
Correcto
|
0.019 s | 1 KBi |
#9 |
Correcto
|
0.032 s | 1 KBi |
#10 |
Correcto
|
0.032 s | 1 KBi |
#11 |
Correcto
|
0.032 s | 1 KBi |
#12 |
Correcto
|
0.032 s | 1 KBi |
#13 |
Correcto
|
0.033 s | 1 KBi |
#14 |
Correcto
|
0.033 s | 1 KBi |
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> arr = vector<int>(n); vector<int> cache = vector<int>(n); int sum = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; // update cache sum += arr[i]; cache[i] = sum; } int m, p, q; cin >> m; for (int i = 0; i < m; i++) { cin >> p >> q; if (p == 0) sum = cache[q]; else sum = cache[q] - cache[p - 1]; cout << sum << endl; } return 0; }