Submission #7477767


Source Code Expand

Copy
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    
    List<List<Integer>> ll = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      boolean found = false;
      for (List<Integer> l : ll) {
        int aa = l.get(l.size()-1);
        while(aa < a[i]) {
          aa *= 2;
        }
        if (aa == a[i]) {
          l.add(a[i]);
          found = true;
          break;
        }
      }
      if (!found) {
        List<Integer> list = new ArrayList<>();
        list.add(a[i]);
        ll.add(list);
      }
    }
    
    System.out.println(ll.size());
  }
}

Submission Info

Submission Time
Task C - 高橋くんと魔法の箱
User sfuku7
Language Java8 (OpenJDK 1.8.0)
Score 20
Code Size 823 Byte
Status
Exec Time 2109 ms
Memory 50824 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 subtask0_0.txt, subtask0_1.txt, subtask0_2.txt
Subtask1 20 / 20 subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_2.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt, subtask0_0.txt, subtask0_1.txt, subtask0_2.txt
Subtask2 0 / 30 subtask2_0.txt, subtask2_1.txt, subtask2_2.txt, subtask2_3.txt, subtask2_4.txt, subtask2_5.txt, subtask2_6.txt, subtask2_7.txt, subtask2_8.txt, subtask2_9.txt, subtask0_0.txt, subtask0_1.txt, subtask0_2.txt
All 0 / 50 subtask0_0.txt, subtask0_1.txt, subtask0_2.txt, subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_2.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt, subtask2_0.txt, subtask2_1.txt, subtask2_2.txt, subtask2_3.txt, subtask2_4.txt, subtask2_5.txt, subtask2_6.txt, subtask2_7.txt, subtask2_8.txt, subtask2_9.txt, subtask3_0.txt, subtask3_1.txt, subtask3_2.txt, subtask3_3.txt, subtask3_4.txt, subtask3_5.txt, subtask3_6.txt, subtask3_7.txt, subtask3_8.txt, subtask3_9.txt
Case Name Status Exec Time Memory
subtask0_0.txt 99 ms 19284 KB
subtask0_1.txt 98 ms 18764 KB
subtask0_2.txt 96 ms 21716 KB
subtask1_0.txt 239 ms 25716 KB
subtask1_1.txt 253 ms 24188 KB
subtask1_10.txt 231 ms 23292 KB
subtask1_11.txt 244 ms 24060 KB
subtask1_12.txt 240 ms 24956 KB
subtask1_13.txt 240 ms 24900 KB
subtask1_14.txt 250 ms 26488 KB
subtask1_15.txt 241 ms 25708 KB
subtask1_16.txt 235 ms 25196 KB
subtask1_17.txt 242 ms 22352 KB
subtask1_18.txt 249 ms 24420 KB
subtask1_19.txt 250 ms 24924 KB
subtask1_2.txt 241 ms 23864 KB
subtask1_3.txt 234 ms 24892 KB
subtask1_4.txt 277 ms 23548 KB
subtask1_5.txt 253 ms 26488 KB
subtask1_6.txt 260 ms 26720 KB
subtask1_7.txt 258 ms 27064 KB
subtask1_8.txt 260 ms 24664 KB
subtask1_9.txt 263 ms 26372 KB
subtask2_0.txt 2109 ms 46200 KB
subtask2_1.txt 2109 ms 48456 KB
subtask2_2.txt 2109 ms 47400 KB
subtask2_3.txt 2109 ms 45000 KB
subtask2_4.txt 2109 ms 49604 KB
subtask2_5.txt 2109 ms 48784 KB
subtask2_6.txt 2109 ms 49292 KB
subtask2_7.txt 2109 ms 46756 KB
subtask2_8.txt 2109 ms 49328 KB
subtask2_9.txt 2109 ms 48232 KB
subtask3_0.txt 2109 ms 47968 KB
subtask3_1.txt 2109 ms 48472 KB
subtask3_2.txt 2109 ms 46304 KB
subtask3_3.txt 2105 ms 48572 KB
subtask3_4.txt 2109 ms 50824 KB
subtask3_5.txt 2109 ms 50564 KB
subtask3_6.txt 2109 ms 48444 KB
subtask3_7.txt 2109 ms 48512 KB
subtask3_8.txt 2109 ms 49392 KB
subtask3_9.txt 2109 ms 49664 KB