Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 2 KBi |
#2 |
Correcto
|
0.006 s | 2 KBi |
#3 |
Correcto
|
0.007 s | 1 KBi |
#4 |
Correcto
|
0.007 s | 2 KBi |
#5 |
Correcto
|
0.005 s | 2 KBi |
#6 |
Correcto
|
0.005 s | 1 KBi |
#7 |
Correcto
|
0.008 s | 1 KBi |
#8 |
Correcto
|
0.04 s | 2 KBi |
#9 |
Correcto
|
0.23 s | 2 KBi |
#10 |
Correcto
|
0.182 s | 2 KBi |
#11 |
Correcto
|
0.229 s | 2 KBi |
#12 |
Correcto
|
0.185 s | 2 KBi |
#13 |
Correcto
|
0.19 s | 2 KBi |
#14 |
Correcto
|
0.177 s | 2 KBi |
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n,veces,p,q; cin >> n; vector<int>arr(n); vector<int>aux(n); for(int i = 0; i < n ; ++i){ cin >> arr[i]; } aux[0]=arr[0]; for(int k = 1; k < n ; ++k){ aux[k] = aux[k-1]+arr[k]; } cin >> veces; for(int j = 0; j < veces ; ++j){ cin >> p >> q; if(p==0){ cout << aux[q] << endl; }else{ cout << aux[q]-aux[p-1] << endl; } } return 0; }