View Code of Problem 88

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String[] s=scanner.nextLine().split(" ");
        int[] dp=new int[s.length];
        for(int i=0;i<6;i++){
            dp[i]=Integer.parseInt(s[i]);
        }
        int ans=dp[5]+dp[4]+dp[3]+dp[2]/4;
        dp[0]-=dp[5]*11;
        dp[1]-=dp[4]*5;
        dp[2]-=dp[2]/4*4;
        if(dp[2]>0){
            ans++;
            switch (dp[2]){
                case 1:
                    dp[1]-=4;
                    dp[0]-=11;
                    break;
                case 2:
                    dp[1]-=3;
                    dp[0]-=6;
                    break;
                case 3:
                    dp[1]-=1;
                    dp[0]-=5;
            }
        }
        if(dp[1]>0){
            ans+=dp[1]/9+1;
            dp[1]%=9;
            dp[0]-=36-dp[1]*4;
        }
        if(dp[0]>0){
            ans+=dp[0]/36+1;
        }
        System.out.print(ans);
    }
}

Double click to view unformatted code.


Back to problem 88