Submission #155093
Source Code Expand
import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.*; public class Main { private static final int mod = (int)1e9+7; final Random random = new Random(0); final IOFast io = new IOFast(); /// MAIN CODE public void run() throws IOException { // int TEST_CASE = Integer.parseInt(new String(io.nextLine()).trim()); int TEST_CASE = 1; while(TEST_CASE-- != 0) { int n = io.nextInt(); int m = io.nextInt(); for(int i = 0; i <= n && i * 3 <= m; i++) { int v = m - i * 3; int low = -1, high = n - i; while(high - low > 1) { int mid = (low + high) / 2; // System.err.println(i + " " + low + " " + high + " " + mid + " " + (mid * 2 + (n - i - mid) * 4) + " " + v); if(mid * 2 + (n - i - mid) * 4 <= v) { high = mid; } else { low = mid; } } if(high * 2 + (n - i - high) * 4 == v) { io.out.println(high + " " + i + " " + (n - i - high)); return; } } io.out.println("-1 -1 -1"); } } /// TEMPLATE static int gcd(int n, int r) { return r == 0 ? n : gcd(r, n%r); } static long gcd(long n, long r) { return r == 0 ? n : gcd(r, n%r); } static <T> void swap(T[] x, int i, int j) { T t = x[i]; x[i] = x[j]; x[j] = t; } static void swap(int[] x, int i, int j) { int t = x[i]; x[i] = x[j]; x[j] = t; } static void radixSort(int[] xs) { int[] cnt = new int[(1<<16)+1]; int[] ys = new int[xs.length]; for(int j = 0; j <= 16; j += 16) { Arrays.fill(cnt, 0); for(int x : xs) { cnt[(x>>j&0xFFFF)+1]++; } for(int i = 1; i < cnt.length; i++) { cnt[i] += cnt[i-1]; } for(int x : xs) { ys[cnt[x>>j&0xFFFF]++] = x; } { final int[] t = xs; xs = ys; ys = t; } } } static void radixSort(long[] xs) { int[] cnt = new int[(1<<16)+1]; long[] ys = new long[xs.length]; for(int j = 0; j <= 48; j += 16) { Arrays.fill(cnt, 0); for(long x : xs) { cnt[(int)(x>>j&0xFFFF)+1]++; } for(int i = 1; i < cnt.length; i++) { cnt[i] += cnt[i-1]; } for(long x : xs) { ys[cnt[(int)(x>>j&0xFFFF)]++] = x; } { final long[] t = xs; xs = ys; ys = t; } } } static void arrayIntSort(int[][] x, int... keys) { Arrays.sort(x, new ArrayIntsComparator(keys)); } static class ArrayIntsComparator implements Comparator<int[]> { final int[] KEY; public ArrayIntsComparator(int... key) { KEY = key; } @Override public int compare(int[] o1, int[] o2) { for(int k : KEY) if(o1[k] != o2[k]) return o1[k] - o2[k]; return 0; } } static class ArrayIntComparator implements Comparator<int[]> { final int KEY; public ArrayIntComparator(int key) { KEY = key; } @Override public int compare(int[] o1, int[] o2) { return o1[KEY] - o2[KEY]; } } void main() throws IOException { // IOFast.setFileIO("rle-size.in", "rle-size.out"); try { run(); } catch (EndOfFileRuntimeException e) { } io.out.flush(); } public static void main(String[] args) throws IOException { new Main().main(); } static class EndOfFileRuntimeException extends RuntimeException { private static final long serialVersionUID = -8565341110209207657L; } static public class IOFast { private BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); private PrintWriter out = new PrintWriter(System.out); void setFileIO(String ins, String outs) throws IOException { out.flush(); out.close(); in.close(); in = new BufferedReader(new FileReader(ins)); out = new PrintWriter(new FileWriter(outs)); System.err.println("reading from " + ins); } // private static final int BUFFER_SIZE = 50 * 200000; private static int pos, readLen; private static final char[] buffer = new char[1024 * 8]; private static char[] str = new char[500*8*2]; private static boolean[] isDigit = new boolean[256]; private static boolean[] isSpace = new boolean[256]; private static boolean[] isLineSep = new boolean[256]; static { for(int i = 0; i < 10; i++) { isDigit['0' + i] = true; } isDigit['-'] = true; isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true; isLineSep['\r'] = isLineSep['\n'] = true; } public int read() throws IOException { if(pos >= readLen) { pos = 0; readLen = in.read(buffer); if(readLen <= 0) { throw new EndOfFileRuntimeException(); } } return buffer[pos++]; } public int nextInt() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; int ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; // return Integer.parseInt(nextString()); } public long nextLong() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; long ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; // return Long.parseLong(nextString()); } public char nextChar() throws IOException { while(true) { final int c = read(); if(!isSpace[c]) { return (char)c; } } } int reads(int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } if(str.length == len) { char[] rep = new char[str.length * 3 / 2]; System.arraycopy(str, 0, rep, 0, str.length); str = rep; } str[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; } int reads(char[] cs, int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } cs[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; } public char[] nextLine() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isLineSep); try { if(str[len-1] == '\r') { len--; read(); } } catch(EndOfFileRuntimeException e) { ; } return Arrays.copyOf(str, len); } public String nextString() throws IOException { return new String(next()); } public char[] next() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); return Arrays.copyOf(str, len); } public int next(char[] cs) throws IOException { int len = 0; cs[len++] = nextChar(); len = reads(cs, len, isSpace); return len; } public double nextDouble() throws IOException { return Double.parseDouble(nextString()); } public long[] nextLongArray(final int n) throws IOException { final long[] res = new long[n]; for(int i = 0; i < n; i++) { res[i] = nextLong(); } return res; } public int[] nextIntArray(final int n) throws IOException { final int[] res = new int[n]; for(int i = 0; i < n; i++) { res[i] = nextInt(); } return res; } public int[][] nextIntArray2D(final int n, final int k) throws IOException { final int[][] res = new int[n][]; for(int i = 0; i < n; i++) { res[i] = nextIntArray(k); } return res; } public int[][] nextIntArray2DWithIndex(final int n, final int k) throws IOException { final int[][] res = new int[n][k+1]; for(int i = 0; i < n; i++) { for(int j = 0; j < k; j++) { res[i][j] = nextInt(); } res[i][k] = i; } return res; } public double[] nextDoubleArray(final int n) throws IOException { final double[] res = new double[n]; for(int i = 0; i < n; i++) { res[i] = nextDouble(); } return res; } } }
Submission Info
Submission Time | |
---|---|
Task | C - スフィンクスのなぞなぞ |
User | tanzaku |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 8016 Byte |
Status | AC |
Exec Time | 604 ms |
Memory | 21688 KB |
Judge Result
Set Name | smallA | smallB | all | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 10 / 10 | 20 / 20 | 70 / 70 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
smallA | test_1-1_ABC.txt, test_1-500_ABC.txt, test_100-103_ABC.txt, test_100-199_ABC.txt, test_100-1_ABC.txt, test_100-200_ABC.txt, test_100-201_ABC.txt, test_100-229_ABC.txt, test_100-300_ABC.txt, test_100-301_ABC.txt, test_100-399_ABC.txt, test_100-400_ABC.txt, test_100-401_ABC.txt, test_100-431_ABC.txt, test_100-473_ABC.txt, test_100-500_ABC.txt, test_33-106_ABC.txt, test_33-131_ABC.txt, test_33-132_ABC.txt, test_33-133_ABC.txt, test_33-134_ABC.txt, test_33-146_ABC.txt, test_33-51_ABC.txt, test_33-65_ABC.txt, test_33-66_ABC.txt, test_33-67_ABC.txt, test_33-71_ABC.txt, test_92-183_ABC.txt, test_92-184_ABC.txt, test_92-185_ABC.txt, test_92-310_ABC.txt, test_92-34_ABC.txt, test_92-367_ABC.txt, test_92-368_ABC.txt, test_92-369_ABC.txt, test_92-391_ABC.txt, test_92-434_ABC.txt, test_92-459_ABC.txt |
smallB | test_1-1_ABC.txt, test_1-500_ABC.txt, test_1-7500_AB.txt, test_100-103_ABC.txt, test_100-199_ABC.txt, test_100-1_ABC.txt, test_100-200_ABC.txt, test_100-201_ABC.txt, test_100-229_ABC.txt, test_100-300_ABC.txt, test_100-301_ABC.txt, test_100-399_ABC.txt, test_100-400_ABC.txt, test_100-401_ABC.txt, test_100-431_ABC.txt, test_100-473_ABC.txt, test_100-500_ABC.txt, test_100-7500_AB.txt, test_1500-1_AB.txt, test_1500-2999_AB.txt, test_1500-3000_AB.txt, test_1500-3001_AB.txt, test_1500-4072_AB.txt, test_1500-477_AB.txt, test_1500-500_AB.txt, test_1500-5768_AB.txt, test_1500-5999_AB.txt, test_1500-6000_AB.txt, test_1500-6001_AB.txt, test_1500-6268_AB.txt, test_1500-7024_AB.txt, test_1500-7500_AB.txt, test_33-106_ABC.txt, test_33-131_ABC.txt, test_33-132_ABC.txt, test_33-133_ABC.txt, test_33-134_ABC.txt, test_33-146_ABC.txt, test_33-51_ABC.txt, test_33-65_ABC.txt, test_33-66_ABC.txt, test_33-67_ABC.txt, test_33-71_ABC.txt, test_578-114_AB.txt, test_578-1155_AB.txt, test_578-1156_AB.txt, test_578-1157_AB.txt, test_578-1984_AB.txt, test_578-2101_AB.txt, test_578-2230_AB.txt, test_578-2311_AB.txt, test_578-2312_AB.txt, test_578-2313_AB.txt, test_578-2728_AB.txt, test_92-183_ABC.txt, test_92-184_ABC.txt, test_92-185_ABC.txt, test_92-310_ABC.txt, test_92-34_ABC.txt, test_92-367_ABC.txt, test_92-368_ABC.txt, test_92-369_ABC.txt, test_92-391_ABC.txt, test_92-434_ABC.txt, test_92-459_ABC.txt |
all | test_1-1_ABC.txt, test_1-500000_A.txt, test_1-500_ABC.txt, test_1-7500_AB.txt, test_100-103_ABC.txt, test_100-199_ABC.txt, test_100-1_ABC.txt, test_100-200_ABC.txt, test_100-201_ABC.txt, test_100-229_ABC.txt, test_100-300_ABC.txt, test_100-301_ABC.txt, test_100-399_ABC.txt, test_100-400_ABC.txt, test_100-401_ABC.txt, test_100-431_ABC.txt, test_100-473_ABC.txt, test_100-500000_A.txt, test_100-500_ABC.txt, test_100-7500_AB.txt, test_100000-175737_A.txt, test_100000-199999_A.txt, test_100000-1_A.txt, test_100000-200000_A.txt, test_100000-200001_A.txt, test_100000-300000_A.txt, test_100000-300001_A.txt, test_100000-321428_A.txt, test_100000-383852_A.txt, test_100000-399999_A.txt, test_100000-400000_A.txt, test_100000-400001_A.txt, test_100000-461143_A.txt, test_100000-482033_A.txt, test_100000-500000_A.txt, test_100000-500_A.txt, test_100000-7500_A.txt, test_12376-24751_A.txt, test_12376-24752_A.txt, test_12376-24753_A.txt, test_12376-4187_A.txt, test_12376-46199_A.txt, test_12376-49503_A.txt, test_12376-49504_A.txt, test_12376-49505_A.txt, test_12376-53158_A.txt, test_12376-57785_A.txt, test_12376-60441_A.txt, test_1500-1_AB.txt, test_1500-2999_AB.txt, test_1500-3000_AB.txt, test_1500-3001_AB.txt, test_1500-4072_AB.txt, test_1500-477_AB.txt, test_1500-500000_A.txt, test_1500-500_AB.txt, test_1500-5768_AB.txt, test_1500-5999_AB.txt, test_1500-6000_AB.txt, test_1500-6001_AB.txt, test_1500-6268_AB.txt, test_1500-7024_AB.txt, test_1500-7500_AB.txt, test_1931-2546_A.txt, test_1931-3861_A.txt, test_1931-3862_A.txt, test_1931-3863_A.txt, test_1931-6721_A.txt, test_1931-7547_A.txt, test_1931-7723_A.txt, test_1931-7724_A.txt, test_1931-7725_A.txt, test_1931-8765_A.txt, test_1931-9463_A.txt, test_33-106_ABC.txt, test_33-131_ABC.txt, test_33-132_ABC.txt, test_33-133_ABC.txt, test_33-134_ABC.txt, test_33-146_ABC.txt, test_33-51_ABC.txt, test_33-65_ABC.txt, test_33-66_ABC.txt, test_33-67_ABC.txt, test_33-71_ABC.txt, test_578-114_AB.txt, test_578-1155_AB.txt, test_578-1156_AB.txt, test_578-1157_AB.txt, test_578-1984_AB.txt, test_578-2101_AB.txt, test_578-2230_AB.txt, test_578-2311_AB.txt, test_578-2312_AB.txt, test_578-2313_AB.txt, test_578-2728_AB.txt, test_84391-168781_A.txt, test_84391-168782_A.txt, test_84391-168783_A.txt, test_84391-263979_A.txt, test_84391-294799_A.txt, test_84391-337563_A.txt, test_84391-337564_A.txt, test_84391-337565_A.txt, test_84391-407535_A.txt, test_84391-420642_A.txt, test_84391-98907_A.txt, test_92-183_ABC.txt, test_92-184_ABC.txt, test_92-185_ABC.txt, test_92-310_ABC.txt, test_92-34_ABC.txt, test_92-367_ABC.txt, test_92-368_ABC.txt, test_92-369_ABC.txt, test_92-391_ABC.txt, test_92-434_ABC.txt, test_92-459_ABC.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 461 ms | 20652 KB |
sample_02.txt | AC | 414 ms | 20648 KB |
sample_03.txt | AC | 418 ms | 20776 KB |
test_1-1_ABC.txt | AC | 409 ms | 20632 KB |
test_1-500000_A.txt | AC | 414 ms | 20780 KB |
test_1-500_ABC.txt | AC | 420 ms | 20780 KB |
test_1-7500_AB.txt | AC | 406 ms | 20656 KB |
test_100-103_ABC.txt | AC | 405 ms | 20784 KB |
test_100-199_ABC.txt | AC | 413 ms | 20756 KB |
test_100-1_ABC.txt | AC | 415 ms | 20656 KB |
test_100-200_ABC.txt | AC | 411 ms | 20648 KB |
test_100-201_ABC.txt | AC | 410 ms | 20632 KB |
test_100-229_ABC.txt | AC | 419 ms | 20656 KB |
test_100-300_ABC.txt | AC | 418 ms | 20648 KB |
test_100-301_ABC.txt | AC | 412 ms | 20784 KB |
test_100-399_ABC.txt | AC | 415 ms | 20656 KB |
test_100-400_ABC.txt | AC | 412 ms | 20656 KB |
test_100-401_ABC.txt | AC | 409 ms | 20648 KB |
test_100-431_ABC.txt | AC | 411 ms | 20656 KB |
test_100-473_ABC.txt | AC | 413 ms | 20788 KB |
test_100-500000_A.txt | AC | 425 ms | 20780 KB |
test_100-500_ABC.txt | AC | 414 ms | 20788 KB |
test_100-7500_AB.txt | AC | 411 ms | 20656 KB |
test_100000-175737_A.txt | AC | 438 ms | 21604 KB |
test_100000-199999_A.txt | AC | 451 ms | 21680 KB |
test_100000-1_A.txt | AC | 406 ms | 20784 KB |
test_100000-200000_A.txt | AC | 409 ms | 20776 KB |
test_100000-200001_A.txt | AC | 412 ms | 20776 KB |
test_100000-300000_A.txt | AC | 414 ms | 20776 KB |
test_100000-300001_A.txt | AC | 411 ms | 20652 KB |
test_100000-321428_A.txt | AC | 412 ms | 20664 KB |
test_100000-383852_A.txt | AC | 407 ms | 20660 KB |
test_100000-399999_A.txt | AC | 408 ms | 20652 KB |
test_100000-400000_A.txt | AC | 412 ms | 20756 KB |
test_100000-400001_A.txt | AC | 432 ms | 21688 KB |
test_100000-461143_A.txt | AC | 431 ms | 21684 KB |
test_100000-482033_A.txt | AC | 462 ms | 21676 KB |
test_100000-500000_A.txt | AC | 447 ms | 21544 KB |
test_100000-500_A.txt | AC | 437 ms | 20700 KB |
test_100000-7500_A.txt | AC | 449 ms | 21040 KB |
test_12376-24751_A.txt | AC | 430 ms | 21296 KB |
test_12376-24752_A.txt | AC | 417 ms | 20660 KB |
test_12376-24753_A.txt | AC | 413 ms | 20652 KB |
test_12376-4187_A.txt | AC | 427 ms | 21096 KB |
test_12376-46199_A.txt | AC | 416 ms | 20656 KB |
test_12376-49503_A.txt | AC | 427 ms | 20664 KB |
test_12376-49504_A.txt | AC | 413 ms | 20672 KB |
test_12376-49505_A.txt | AC | 438 ms | 21296 KB |
test_12376-53158_A.txt | AC | 435 ms | 21296 KB |
test_12376-57785_A.txt | AC | 431 ms | 21284 KB |
test_12376-60441_A.txt | AC | 438 ms | 21300 KB |
test_1500-1_AB.txt | AC | 414 ms | 20656 KB |
test_1500-2999_AB.txt | AC | 413 ms | 20660 KB |
test_1500-3000_AB.txt | AC | 418 ms | 20660 KB |
test_1500-3001_AB.txt | AC | 408 ms | 20652 KB |
test_1500-4072_AB.txt | AC | 408 ms | 20648 KB |
test_1500-477_AB.txt | AC | 407 ms | 20660 KB |
test_1500-500000_A.txt | AC | 415 ms | 20656 KB |
test_1500-500_AB.txt | AC | 417 ms | 20660 KB |
test_1500-5768_AB.txt | AC | 414 ms | 20628 KB |
test_1500-5999_AB.txt | AC | 413 ms | 20652 KB |
test_1500-6000_AB.txt | AC | 412 ms | 20648 KB |
test_1500-6001_AB.txt | AC | 409 ms | 20656 KB |
test_1500-6268_AB.txt | AC | 407 ms | 20644 KB |
test_1500-7024_AB.txt | AC | 412 ms | 20656 KB |
test_1500-7500_AB.txt | AC | 411 ms | 20652 KB |
test_1931-2546_A.txt | AC | 415 ms | 20644 KB |
test_1931-3861_A.txt | AC | 420 ms | 20644 KB |
test_1931-3862_A.txt | AC | 414 ms | 20660 KB |
test_1931-3863_A.txt | AC | 420 ms | 20652 KB |
test_1931-6721_A.txt | AC | 411 ms | 20784 KB |
test_1931-7547_A.txt | AC | 411 ms | 20648 KB |
test_1931-7723_A.txt | AC | 408 ms | 20640 KB |
test_1931-7724_A.txt | AC | 407 ms | 20656 KB |
test_1931-7725_A.txt | AC | 604 ms | 21012 KB |
test_1931-8765_A.txt | AC | 551 ms | 20908 KB |
test_1931-9463_A.txt | AC | 420 ms | 21168 KB |
test_33-106_ABC.txt | AC | 413 ms | 20652 KB |
test_33-131_ABC.txt | AC | 410 ms | 20652 KB |
test_33-132_ABC.txt | AC | 412 ms | 20780 KB |
test_33-133_ABC.txt | AC | 413 ms | 20652 KB |
test_33-134_ABC.txt | AC | 418 ms | 20792 KB |
test_33-146_ABC.txt | AC | 414 ms | 20780 KB |
test_33-51_ABC.txt | AC | 419 ms | 20652 KB |
test_33-65_ABC.txt | AC | 418 ms | 20784 KB |
test_33-66_ABC.txt | AC | 416 ms | 20656 KB |
test_33-67_ABC.txt | AC | 419 ms | 20664 KB |
test_33-71_ABC.txt | AC | 419 ms | 20644 KB |
test_578-114_AB.txt | AC | 414 ms | 20628 KB |
test_578-1155_AB.txt | AC | 408 ms | 20652 KB |
test_578-1156_AB.txt | AC | 414 ms | 20652 KB |
test_578-1157_AB.txt | AC | 411 ms | 20624 KB |
test_578-1984_AB.txt | AC | 414 ms | 20784 KB |
test_578-2101_AB.txt | AC | 429 ms | 20640 KB |
test_578-2230_AB.txt | AC | 409 ms | 20652 KB |
test_578-2311_AB.txt | AC | 414 ms | 20656 KB |
test_578-2312_AB.txt | AC | 415 ms | 20788 KB |
test_578-2313_AB.txt | AC | 420 ms | 20652 KB |
test_578-2728_AB.txt | AC | 418 ms | 20780 KB |
test_84391-168781_A.txt | AC | 436 ms | 21552 KB |
test_84391-168782_A.txt | AC | 416 ms | 20652 KB |
test_84391-168783_A.txt | AC | 415 ms | 20648 KB |
test_84391-263979_A.txt | AC | 414 ms | 20656 KB |
test_84391-294799_A.txt | AC | 417 ms | 20780 KB |
test_84391-337563_A.txt | AC | 416 ms | 20780 KB |
test_84391-337564_A.txt | AC | 414 ms | 20624 KB |
test_84391-337565_A.txt | AC | 434 ms | 21548 KB |
test_84391-407535_A.txt | AC | 434 ms | 21552 KB |
test_84391-420642_A.txt | AC | 435 ms | 21552 KB |
test_84391-98907_A.txt | AC | 436 ms | 21680 KB |
test_92-183_ABC.txt | AC | 418 ms | 20644 KB |
test_92-184_ABC.txt | AC | 415 ms | 20652 KB |
test_92-185_ABC.txt | AC | 415 ms | 20644 KB |
test_92-310_ABC.txt | AC | 415 ms | 20656 KB |
test_92-34_ABC.txt | AC | 411 ms | 20652 KB |
test_92-367_ABC.txt | AC | 420 ms | 20624 KB |
test_92-368_ABC.txt | AC | 411 ms | 20784 KB |
test_92-369_ABC.txt | AC | 411 ms | 20648 KB |
test_92-391_ABC.txt | AC | 411 ms | 20652 KB |
test_92-434_ABC.txt | AC | 413 ms | 20656 KB |
test_92-459_ABC.txt | AC | 414 ms | 20656 KB |