Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 1 KBi |
#2 |
Correcto
|
0.006 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.005 s | 1 KBi |
#5 |
Correcto
|
0.006 s | 1 KBi |
#6 |
Correcto
|
0.006 s | 1 KBi |
#7 |
Correcto
|
0.007 s | 1 KBi |
#8 |
Correcto
|
0.044 s | 1 KBi |
#9 |
Correcto
|
0.197 s | 2 KBi |
#10 |
Correcto
|
0.217 s | 2 KBi |
#11 |
Correcto
|
0.204 s | 2 KBi |
#12 |
Correcto
|
0.215 s | 2 KBi |
#13 |
Correcto
|
0.199 s | 2 KBi |
#14 |
Correcto
|
0.21 s | 2 KBi |
#include <iostream> #include <cstring> #include <cstdio> #include <cmath> #include <queue> #include <set> #include <map> #include <vector> #include <stack> #include <algorithm> using namespace std; int main() { int n, c, x, y; int a[50001]; int p[50001]; cin>>n; for(int i = 0; i < n; i++) { cin>>a[i]; if(i==0) p[i] = a[i]; else p[i] = p[i-1] + a[i]; } cin>>c; /*cout<<endl<<"RES:"<<endl; for(int i = 0; i < n; i++) { cout<<p[i]<<endl; }*/ for(int i = 0; i < c; i++) { cin>>x>>y; int suma = 0; if(x>0) suma = p[y] - p[x-1]; else suma = p[y]; cout<<suma<<endl; } }