package yukicoder; import java.util.*; public class Q453 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double c = sc.nextDouble(); double d = sc.nextDouble(); /* * 1000x+2000y max 3/4x+2/7y<=c 1/4x+5/7y<=d */ double max = 0; ArrayDeque que = new ArrayDeque<>(); que.add(new Pair(0, Math.min(7.0 / 2.0 * c, 7.0 / 5.0 * d))); que.add(new Pair(Math.min(4.0 / 3.0 * c, 4 * d), 0)); que.add(new Pair(4.0 / 13.0 * (5 * c - 2 * d), 7 * (3 * d - c) / 13.0)); while (!que.isEmpty()) { Pair p = que.poll(); if (p.x < 0 || p.y < 0) continue; max = Math.max(max, 1000 * p.x + 2000 * p.y); } System.out.println(max); } static class Pair { double x; double y; public Pair(double x, double y) { this.x = x; this.y = y; } } }