Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- // Check Examples
- // Compiler version JDK 11.0.2
- class Dcoder
- {
- private static ArrayList<Integer> groups = new ArrayList<Integer>();
- public static void main(String args[])
- {
- Scanner input = new Scanner(System.in);
- int principal = input.nextInt();
- while(--principal > 0)
- addToGroup(shiftGroups(principal));
- if(groups.isEmpty()) groups.add(0);
- System.out.println(groups.size());
- }
- public static boolean shiftGroups(int amount) {
- if(groups.isEmpty()) return true;
- if(groups.size() == 100000-1) return false;
- if(groups.get(groups.size() - 1) < 3) return false;
- return true;
- }
- public static void addToGroup(boolean isShifting) {
- if(isShifting)
- groups.add(0);
- int index = groups.size() - 1;
- int newInt = groups.get(index) + 1;
- groups.set(index, groups.get(index) + 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement