Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 60 KBi |
#2 |
Correcto
|
0.006 s | 2 KBi |
#3 |
Correcto
|
0.006 s | 1 KBi |
#4 |
Correcto
|
0.005 s | 4 KBi |
#5 |
Correcto
|
0.006 s | 2 KBi |
#6 |
Correcto
|
0.007 s | 1 KBi |
#7 |
Correcto
|
0.005 s | 1 KBi |
#8 |
Correcto
|
0.019 s | 1 KBi |
#9 |
Correcto
|
0.04 s | 6 KBi |
#10 |
Correcto
|
0.033 s | 3 KBi |
#11 |
Correcto
|
0.043 s | 10 KBi |
#12 |
Correcto
|
0.033 s | 3 KBi |
#13 |
Correcto
|
0.034 s | 6 KBi |
#14 |
Correcto
|
0.032 s | 5 KBi |
#include <iostream> #include <vector> using namespace std; vector<int> processLine(int N) { int e; vector<int> sum(N); cin >> e; sum[0] = e; for (int i = 1; i < N; i++) { cin >> e; sum[i] += sum[i-1] + e; } return sum; } int main() { int N, C, from, to, sum; vector<int> elements; cin >> N; elements = processLine(N); cin >> C; for (int i = 0; i < C; i++) { cin >> from; cin >> to; sum = elements[to]; if (from - 1 >= 0) sum -= elements[from - 1]; cout << sum << endl; } }