Submission #4043498


Source Code Expand

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        int ans = 5000 * 2 * 100000 + 1;
        int maxZ = 2 * Math.max(x, y);
        for (int i_z = 0; i_z <= maxZ; i_z++) {
            int i_x = Math.max(0, x - i_z / 2);
            int i_y = Math.max(0, y - i_z / 2);
            ans = Math.min(ans, a * i_x + b * i_y + c * i_z);
        }
        System.out.println(ans);
    }
}

Submission Info

Submission Time
Task C - Half and Half
User mt_kuma
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 739 Byte
Status AC
Exec Time 114 ms
Memory 23764 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15
Case Name Status Exec Time Memory
a01 AC 94 ms 21332 KB
a02 AC 94 ms 20948 KB
a03 AC 102 ms 21460 KB
b04 AC 92 ms 21076 KB
b05 AC 104 ms 23764 KB
b06 AC 104 ms 21204 KB
b07 AC 104 ms 19792 KB
b08 AC 113 ms 21588 KB
b09 AC 104 ms 21844 KB
b10 AC 104 ms 23124 KB
b11 AC 103 ms 22612 KB
b12 AC 104 ms 23252 KB
b13 AC 114 ms 21460 KB
b14 AC 105 ms 20692 KB
b15 AC 106 ms 21588 KB