Submission #3430172


Source Code Expand

import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
  public static void main(String[] args) throws Exception {
    String line = null;
    double num = 0;
    double rem = 0;
    double res = 0;
    double[] size = {0.25, 0.5, 1, 2};
    double[][] array = new double[4][3];
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    line = br.readLine();
    String price[] = line.split(" ");
    line = br.readLine();
    double vol = Double.parseDouble(line);
    // 配列に1リットルあたりの単価を登録
    array[0][0] = Double.parseDouble(price[0]) * 4;         // 0.25L
    array[1][0] = Double.parseDouble(price[1]) * 2;         // 0.50L
    array[2][0] = Double.parseDouble(price[2]);             // 1.00L
    array[3][0] = (double)Double.parseDouble(price[3]) / 2; // 2.00L
    // 配列にサイズを登録
    for (int i = 0; i < 4; i++) {
      array[i][1] = size[i];
    }
    // 配列に価格を登録
    for (int i = 0; i < 4; i++) {
      array[i][2] = Double.parseDouble(price[i]);
    }
    Arrays.sort(array, new Comparator<double[]>() {
      @Override
      public int compare(double[] o1, double[] o2) {
        if (o1[0] == o2[0]) {
          //サイズでソート(降順)
          if (o2[1] < o1[1]) return -1;
          if (o2[1] > o1[1]) return 1;
          return 0;
        } else {
          //単価でソート(昇順)
          if (o1[0] < o2[0]) return -1;
          if (o1[0] > o2[0]) return 1;
          return 0;
        }
      }
    });
    for (int i = 0; i < 4; i++) {
      if (array[i][1] > vol) {   // サイズが大きかったら買わない
        continue;
      }
      num = vol / array[i][1];   // 買える数
      rem = vol % array[i][1];   // 買えない数
      num = Math.floor(num);     // 小数点以下切り捨て
      res = res + num * array[i][2];
      if (rem == 0) {
        break;
      }
      vol = rem;
    }
    System.out.println((long)res);
  }
}

Submission Info

Submission Time
Task A - Ice Tea Store
User unirita108
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 2054 Byte
Status WA
Exec Time 72 ms
Memory 22740 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 4
AC × 19
WA × 4
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt
Case Name Status Exec Time Memory
sample_01.txt AC 72 ms 19284 KB
sample_02.txt AC 69 ms 21716 KB
sample_03.txt AC 71 ms 19412 KB
sample_04.txt AC 71 ms 18644 KB
subtask_1_01.txt AC 70 ms 19540 KB
subtask_1_02.txt AC 70 ms 21076 KB
subtask_1_03.txt WA 69 ms 19540 KB
subtask_1_04.txt AC 70 ms 19668 KB
subtask_1_05.txt AC 70 ms 17876 KB
subtask_1_06.txt AC 70 ms 20820 KB
subtask_1_07.txt AC 68 ms 19412 KB
subtask_1_08.txt WA 70 ms 20180 KB
subtask_1_09.txt WA 71 ms 18132 KB
subtask_1_10.txt AC 70 ms 18772 KB
subtask_1_11.txt AC 72 ms 22740 KB
subtask_1_12.txt AC 69 ms 18516 KB
subtask_1_13.txt AC 69 ms 20436 KB
subtask_1_14.txt WA 69 ms 20436 KB
subtask_1_15.txt AC 70 ms 21204 KB