█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 634

Problema 0xf2 - Partir un arreglo grande en 2

  • Autor: Mejibyte
  • Fecha: 2020-09-12 21:43:00 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.006 s 5 KBi
#2
Correcto
0.005 s 5 KBi
#3
Correcto
0.005 s 3 KBi
#4
Correcto
0.005 s 1 KBi
#5
Correcto
0.005 s 16 KBi
#6
Correcto
0.005 s 1 KBi
#7
Correcto
0.005 s 2 KBi
#8
Correcto
0.006 s 3 KBi
#9
Correcto
0.006 s 1 KBi
#10
Correcto
0.005 s 1 KBi
#11
Correcto
0.007 s 1 KBi
#12
Correcto
0.006 s 2 KBi
#13
Correcto
0.006 s 1 KBi
#14
Tiempo límite excedido
0.635 s 3 KBi
#15
Tiempo límite excedido
0.663 s 3 KBi
#16
Tiempo límite excedido
0.675 s 3 KBi
#17
Tiempo límite excedido
0.736 s 3 KBi
#18
Correcto
0.087 s 3 KBi
#19
Tiempo límite excedido
1.01 s 3 KBi
#20
Tiempo límite excedido
0.626 s 3 KBi
Puntos totales: 70 / 100

Código

#include <vector>
#include <iostream>
using namespace std;

void solve(const vector<int> &a, int n) {
  for (int r = 0; r < n; ++r) {
    int left = 0, right = 0;
    for (int i = 0; i < r; ++i) {
      left += a[i];
    }
    for (int i = r; i < n; ++i) {
      right += a[i];
    }
    if (left > 0 and right < 0) {
      cout << r << endl;
      return;
    }
  }
  cout << "Impossible" << endl;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  solve(a, n);
  return 0;
}