Submission #1949079
Source Code Expand
import java.io.IOException; import java.io.InputStream; import java.util.NoSuchElementException; public class Main { public static void main(String[] args) { FastScanner sc = new FastScanner(); int n = sc.nextInt(); int y = sc.nextInt(); int a = y / 10000; y -= a * 10000; int b = y / 5000; y -= b * 5000; int c = y / 1000; y -= c * 1000; if (y > 0 || a + b + c > n) { System.out.println("-1 -1 -1"); } else { int dif = n - (a + b + c); int tmp = Math.min(a, dif / 9); a -= tmp; c += tmp * 10; dif = n - (a + b + c); tmp = Math.min(b, dif / 4); b -= tmp; c += tmp * 5; dif = n - (a + b + c); tmp = Math.min(a, dif); a -= tmp; b += tmp * 2; if (a + b + c == n) { System.out.println(a + " " + b + " " + c); } else { System.out.println("-1 -1 -1"); } } } } class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) return true; else { ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) return false; } return true; } private byte readByte() { if (hasNextByte()) return buffer[ptr++]; return -1; } private boolean isPrintableChar(byte c) { return '!' <= c && c <= '~'; } private void skipUnprintable() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) { ptr++; } } public boolean hasNext() { skipUnprintable(); return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); byte b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public int nextInt() { if (!hasNext()) throw new NoSuchElementException(); int n = 0; boolean minus = false; byte b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) throw new NumberFormatException(); while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = nextInt(); } return a; } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; byte b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) throw new NumberFormatException(); while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } public long[] nextLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) { a[i] = nextInt(); } return a; } }
Submission Info
Submission Time | |
---|---|
Task | C - Otoshidama |
User | deka0106 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 3274 Byte |
Status | AC |
Exec Time | 96 ms |
Memory | 22100 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | a01, a02, a03, a04 |
All | a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
a01 | AC | 69 ms | 18772 KB |
a02 | AC | 68 ms | 20692 KB |
a03 | AC | 69 ms | 18388 KB |
a04 | AC | 69 ms | 20692 KB |
b05 | AC | 69 ms | 19156 KB |
b06 | AC | 69 ms | 15700 KB |
b07 | AC | 70 ms | 20564 KB |
b08 | AC | 68 ms | 21204 KB |
b09 | AC | 96 ms | 20948 KB |
b10 | AC | 68 ms | 19284 KB |
b11 | AC | 69 ms | 19924 KB |
b12 | AC | 70 ms | 18644 KB |
b13 | AC | 70 ms | 18132 KB |
b14 | AC | 71 ms | 16852 KB |
b15 | AC | 69 ms | 22100 KB |
b16 | AC | 68 ms | 18388 KB |
b17 | AC | 70 ms | 19156 KB |
b18 | AC | 68 ms | 19156 KB |
b19 | AC | 70 ms | 18132 KB |
b20 | AC | 72 ms | 20692 KB |
b21 | AC | 70 ms | 18260 KB |
b22 | AC | 68 ms | 20692 KB |
b23 | AC | 68 ms | 17748 KB |
b24 | AC | 69 ms | 21332 KB |