Submission #1540613
Source Code Expand
import java.io.*; import java.util.*; import static java.util.stream.Collectors.groupingBy; public class Main { class Bottle implements Comparable<Bottle> { double capacity; int price; public Bottle(double capacity, int price) { this.capacity = capacity; this.price = price; } @Override public int compareTo(Bottle o) { return Double.compare(price / capacity, o.price / o.capacity); } } void solve() { double cap = 0.25; Bottle[] bottles = new Bottle[4]; for (int i = 0; i < 4; i++) { int price = in.nextInt(); bottles[i] = new Bottle(cap, price); cap *= 2; } int n = in.nextInt(); long total = 0; Arrays.sort(bottles); for (int i = 0; i < 4 && n > 0; i++) { if (bottles[i].capacity > n) continue; int toBuy = (int) (n / bottles[i].capacity); n -= (int) (toBuy * bottles[i].capacity); total += (long) toBuy * bottles[i].price; } out.println(total); } Scanner in; PrintWriter out; void run() { try { in = new Scanner(new File("A.in")); out = new PrintWriter(new File("A.out")); solve(); out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } } void runIO() { in = new Scanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); } class Scanner { BufferedReader br; StringTokenizer st; public Scanner(File f) { try { br = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException e) { e.printStackTrace(); } } public Scanner(InputStream f) { br = new BufferedReader(new InputStreamReader(f)); } String next() { while (st == null || !st.hasMoreTokens()) { String s = null; try { s = br.readLine(); } catch (IOException e) { e.printStackTrace(); } if (s == null) return null; st = new StringTokenizer(s); } return st.nextToken(); } private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private int skip() { int b; while ((b = read()) != -1 && isSpaceChar(b)) ; return b; } private int read() { int res = -1; try { res = br.read(); } catch (IOException e) { e.printStackTrace(); } return res; } char[] nextCharArray(int size) { char[] buf = new char[size]; int b = skip(), p = 0; while (p < size && !(isSpaceChar(b))) { buf[p++] = (char) b; b = read(); } return size == p ? buf : Arrays.copyOf(buf, p); } char[][] nextCharMap(int n, int m) { char[][] map = new char[n][]; for (int i = 0; i < n; i++) { map[i] = nextCharArray(m); } return map; } boolean hasMoreTokens() { while (st == null || !st.hasMoreTokens()) { String s = null; try { s = br.readLine(); } catch (IOException e) { e.printStackTrace(); } if (s == null) return false; st = new StringTokenizer(s); } return true; } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } } public static void main(String[] args) { new Main().runIO(); } }
Submission Info
Submission Time | |
---|---|
Task | A - Ice Tea Store |
User | serhkry |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 4422 Byte |
Status | AC |
Exec Time | 90 ms |
Memory | 23252 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
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 | 78 ms | 21204 KB |
sample_02.txt | AC | 75 ms | 17108 KB |
sample_03.txt | AC | 73 ms | 20564 KB |
sample_04.txt | AC | 70 ms | 21204 KB |
subtask_1_01.txt | AC | 71 ms | 18388 KB |
subtask_1_02.txt | AC | 90 ms | 23252 KB |
subtask_1_03.txt | AC | 70 ms | 19412 KB |
subtask_1_04.txt | AC | 71 ms | 21460 KB |
subtask_1_05.txt | AC | 70 ms | 19412 KB |
subtask_1_06.txt | AC | 72 ms | 17876 KB |
subtask_1_07.txt | AC | 71 ms | 19540 KB |
subtask_1_08.txt | AC | 71 ms | 21204 KB |
subtask_1_09.txt | AC | 72 ms | 19540 KB |
subtask_1_10.txt | AC | 75 ms | 19028 KB |
subtask_1_11.txt | AC | 75 ms | 16980 KB |
subtask_1_12.txt | AC | 75 ms | 18516 KB |
subtask_1_13.txt | AC | 75 ms | 19796 KB |
subtask_1_14.txt | AC | 76 ms | 19668 KB |
subtask_1_15.txt | AC | 71 ms | 21332 KB |