Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 1 KBi |
#2 |
Correcto
|
0.007 s | 1 KBi |
#3 |
Correcto
|
0.006 s | 1 KBi |
#4 |
Correcto
|
0.006 s | 1 KBi |
#5 |
Correcto
|
0.006 s | 1 KBi |
#6 |
Correcto
|
0.007 s | 1 KBi |
#7 |
Correcto
|
0.007 s | 1 KBi |
#8 |
Correcto
|
0.048 s | 1 KBi |
#9 |
Correcto
|
0.198 s | 3 KBi |
#10 |
Correcto
|
0.207 s | 2 KBi |
#11 |
Correcto
|
0.23 s | 2 KBi |
#12 |
Correcto
|
0.19 s | 2 KBi |
#13 |
Correcto
|
0.206 s | 2 KBi |
#14 |
Correcto
|
0.226 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> v(n); vector<int> aux(n); for(int i=0;i<n;++i){ cin >> v[i]; } aux[0]=v[0]; for(int j=1;j<n;++j){ aux[j]=aux[j-1]+v[j]; } cin >> veces; for(int i=0;i<veces;++i){ cin >> p >> q; if(p==0){ cout << aux[q] <<endl; ; }else{ cout << aux[q]-aux[p-1] <<endl;; } } return 0; }