Submission #439540

# Submission time Handle Problem Language Result Execution time Memory
439540 2021-06-30T08:03:30 Z asc Baloni (COCI15_baloni) Java 11
0 / 100
2000 ms 44820 KB
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class baloni {
    public static void main(String args[]) {
        Scanner sc=new Scanner(System.in);
        int numOfBalloons=sc.nextInt();
        Integer[] arrayOfBalloons=new Integer[numOfBalloons];
        for (int i=0;i<numOfBalloons;i++){
            arrayOfBalloons[i]=sc.nextInt();
        }
        List<Integer> listOfBalloons= new ArrayList<>(Arrays.asList(arrayOfBalloons));
        int numOfArrow=0;
        while (listOfBalloons.isEmpty()==false){
            int currBalloonsIndex=0;
            List<Integer> groupingBalloons= new ArrayList<>();
            groupingBalloons.add(listOfBalloons.get(currBalloonsIndex));
            for (int i = 1; i < listOfBalloons.size(); i++) {
                if (groupingBalloons.get(groupingBalloons.size()-1) - listOfBalloons.get(i) == 1) {
                    groupingBalloons.add(listOfBalloons.get(i));
                }
            }
            Integer[] grouping= new Integer[groupingBalloons.size()];
            for (int i=0;i<groupingBalloons.size();i++){
                grouping[i]=groupingBalloons.get(i);
            }
            for (Integer x:grouping) {
                listOfBalloons.remove(x);
            }
            numOfArrow+=1;

        }
        System.out.println(numOfArrow);
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 290 ms 13052 KB Output isn't correct
2 Incorrect 339 ms 14048 KB Output isn't correct
3 Incorrect 557 ms 15444 KB Output isn't correct
4 Incorrect 635 ms 15592 KB Output isn't correct
5 Execution timed out 2033 ms 38192 KB Time limit exceeded
6 Execution timed out 2067 ms 44820 KB Time limit exceeded
7 Execution timed out 2070 ms 39884 KB Time limit exceeded
8 Execution timed out 2059 ms 39804 KB Time limit exceeded
9 Execution timed out 2061 ms 37632 KB Time limit exceeded
10 Execution timed out 2068 ms 37756 KB Time limit exceeded