Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 1 KBi |
#2 |
Correcto
|
0.006 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 2 KBi |
#4 |
Correcto
|
0.005 s | 2 KBi |
#5 |
Correcto
|
0.007 s | 2 KBi |
#6 |
Correcto
|
0.005 s | 1 KBi |
#7 |
Correcto
|
0.005 s | 1 KBi |
#8 |
Correcto
|
0.038 s | 12 KBi |
#9 |
Correcto
|
0.196 s | 2 KBi |
#10 |
Correcto
|
0.19 s | 1 KBi |
#11 |
Correcto
|
0.185 s | 3 KBi |
#12 |
Correcto
|
0.202 s | 1 KBi |
#13 |
Tiempo límite excedido
|
1.064 s | 2 KBi |
#14 |
Tiempo límite excedido
|
1.006 s | 1 KBi |
#include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> A(N); long sum = 0; for (int i = 0; i < N; ++i) { int Ai; cin >> Ai; sum += Ai; A[i] = Ai; } int C; cin >> C; int p; int q; for (int i = 0; i < C; ++i) { cin >> p; cin >> q; int left = 0; int right = N-1; long total = sum; while (left < p || right > q) { if (left < p) { total -= A[left ++]; } if (right > q) { total -= A[right--]; } } cout << total << endl; } }