Submission #1695941


Source Code Expand

import java.util.*;

public class Main {
    private static final String ex = "17 19 22 26 55 2802";
//    private static final String ex = "2\n" +
//            "9\n" +
//            "3 6";
//    private static final String ex = "5\n" +
//            "20\n" +
//            "11 12 9 17 12";

    public static void main(String[] args) {
        System.out.println(solve(new Scanner(System.in)));
//        System.out.println(solve(new Scanner(ex)));
    }

    private static String solve(Scanner scanner) {
        String[] split = scanner.nextLine().split(" ");
        int A = Integer.parseInt(split[0]);
        int B = Integer.parseInt(split[1]);
        int C = Integer.parseInt(split[2]);
        int D = Integer.parseInt(split[3]);
        int E = Integer.parseInt(split[4]);
        int F = Integer.parseInt(split[5]);

        Set<Integer> X = new HashSet<>();
        Set<Integer> Y = new HashSet<>();

        for (int i = 0; i <= F / (100 * A); i ++) {
            int sum = i * A * 100;
            int j = 0;
            while (sum <= F) {
                X.add(sum);
                sum += j * B * 100;
                j ++;
            }
        }

        for (int i = 0; i <= F / C; i ++) {
            int sum = i * C;
            int j = 0;
            while (sum <= F) {
                Y.add(sum);
                sum += j * D;
                j ++;
            }
        }

        double max = 0;
        int maxXY = 0;
        int maxY = 0;
        for (Integer x: X) {
            for (Integer y: Y) {
                double m = (double) y / (double) (x + y);

                if (x == 0 || m > (double) E / (double) (x + E) || x + y > F) {
                    continue;
                }

                if (max < m) {
                    max = m;
                    maxXY = x + y;
                    maxY = y;
                }
            }
        }

        return maxXY + " " + maxY;
    }
}

Submission Info

Submission Time
Task C - Sugar Water
User g_votte
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 1999 Byte
Status WA
Exec Time 124 ms
Memory 23252 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
WA × 1
AC × 2
WA × 10
Set Name Test Cases
Sample subtask0_0.txt, subtask0_1.txt, subtask0_2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, subtask0_0.txt, subtask0_1.txt, subtask0_2.txt
Case Name Status Exec Time Memory
01.txt WA 106 ms 19284 KB
02.txt WA 121 ms 22356 KB
03.txt WA 107 ms 18900 KB
04.txt WA 118 ms 19284 KB
05.txt WA 124 ms 21716 KB
06.txt WA 117 ms 19024 KB
07.txt WA 111 ms 20820 KB
08.txt WA 120 ms 21460 KB
09.txt WA 104 ms 21204 KB
subtask0_0.txt AC 105 ms 23252 KB
subtask0_1.txt AC 124 ms 19540 KB
subtask0_2.txt WA 102 ms 19796 KB