Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 0 KBi |
#2 |
Correcto
|
0.004 s | 0 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.005 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 1 KBi |
#6 |
Correcto
|
0.004 s | 1 KBi |
#7 |
Correcto
|
0.004 s | 8 KBi |
#8 |
Correcto
|
0.026 s | 1 KBi |
#9 |
Correcto
|
0.073 s | 1 KBi |
#10 |
Correcto
|
0.11 s | 14 KBi |
#11 |
Correcto
|
0.165 s | 2 KBi |
#12 |
Correcto
|
0.077 s | 1 KBi |
#13 |
Correcto
|
0.155 s | 2 KBi |
#14 |
Correcto
|
0.148 s | 2 KBi |
#include <iostream> using namespace std; void solve (int s[], int p, int q); int main() { int n; cin >> n; int a[n]; int s[n]; int sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; s[i] = sum; } int c; cin >> c; for (int i = 0; i < c; i++) { int p, q; cin >> p >> q; solve(s, p, q); } return 0; } void solve (int s[], int p, int q) { if (p == 0) { cout << s[q] << endl; } else { cout << s[q] - s[p-1] << endl; } }