2904 - Super Sum
Forum rules
Remember that posting AC code is not allowed here. If you are going to ask a question or to post a solution, describe your algorithm instead. Posting AC code will be penalized.
Remember that posting AC code is not allowed here. If you are going to ask a question or to post a solution, describe your algorithm instead. Posting AC code will be penalized.
- ymondelo20
- Posts: 1968
- Joined: 8 years ago
- Location: Universidad de las Ciencias Informáticas
- Gender:
- Contact:
Re: 2904 - Super Sum
I'm having RE with this code, I don't know why:
I've tested it with even the worst test cases I could imagine, but works OK on my computer.
Code: Select all
import java.io.*;
import java.math.*;
public class Main {
public static void main (String[] args) throws IOException {
BufferedReader reader = new BufferedReader(
new InputStreamReader(System.in) );
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(System.out));
BigInteger sum = new BigInteger("0");
int t = Integer.parseInt(reader.readLine());
for (int i=0; i<t; i++) {
sum = sum.add(new BigInteger(reader.readLine()));
}
writer.append(sum.toString() + "\n");
writer.flush();
}
}
Re: 2904 - Super Sum
"The first line of input contains an integer T, representing the quantity of number N to add up."
Según yo, ahí se encuentra el detalle del problema. En especifico, lo que dice el enunciado que significa T y lo que estás implementando.
Según yo, ahí se encuentra el detalle del problema. En especifico, lo que dice el enunciado que significa T y lo que estás implementando.
Re: 2904 - Super Sum
Si, ahora entendí... igual es hasta malicioso ese detalle a mi parecer, pero bueno. Ahora que resolví eso, me da TLE. Evidentemente no se puede resolver con BigIntiger no? Pensé que si usaba BufferedReader y BufferedWriter para hacer la lectura y escritura de datos iba a dar bien el tiempo, pero por lo visto no... o es otro el problema?
Ah, y gracias por la respuesta rvargas
Ah, y gracias por la respuesta rvargas

- ymondelo20
- Posts: 1968
- Joined: 8 years ago
- Location: Universidad de las Ciencias Informáticas
- Gender:
- Contact:
Re: 2904 - Super Sum
De hecho, creo que la única manera de resolverlo es con BigInteger, o alguna implementación equivalente para los lenguajes que no tienen ese tipo de datos.
"Every problem has a simple, fast and wrong solution" OJ's Main Law. 

Re: 2904 - Super Sum
@facug91, en Java con Scanner y BigInteger da en tiempo. El problema es que algunos JDs se generaron a mano y tienen lineas en blanco entre los números.. Esto debe tenerse en cuenta en python también a la hora de leer..
- ymondelo20
- Posts: 1968
- Joined: 8 years ago
- Location: Universidad de las Ciencias Informáticas
- Gender:
- Contact:
Re: 2904 - Super Sum
Ya están arreglados los datasets.
Recalificados todos los envíos.
Recalificados todos los envíos.
"Every problem has a simple, fast and wrong solution" OJ's Main Law. 
