Submission #154950
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 * 3 <= m; i++) { int v = m - i * 3; int low = -1, high = n - i; while(high - low > 1) { int mid = (low + high) / 2; if(mid * 2 + (n - i - mid) * 4 < v) { low = mid; } else { high = mid; } } if(high <= n - i && 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 | 0 |
Code Size | 7906 Byte |
Status | WA |
Exec Time | 500 ms |
Memory | 21688 KB |
Judge Result
Set Name | smallA | smallB | all | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 10 | 0 / 20 | 0 / 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 | 490 ms | 20788 KB |
sample_02.txt | AC | 446 ms | 20792 KB |
sample_03.txt | AC | 441 ms | 20792 KB |
test_1-1_ABC.txt | AC | 451 ms | 20664 KB |
test_1-500000_A.txt | AC | 452 ms | 21612 KB |
test_1-500_ABC.txt | AC | 430 ms | 20664 KB |
test_1-7500_AB.txt | AC | 449 ms | 20792 KB |
test_100-103_ABC.txt | AC | 430 ms | 20788 KB |
test_100-199_ABC.txt | AC | 458 ms | 20652 KB |
test_100-1_ABC.txt | AC | 445 ms | 20788 KB |
test_100-200_ABC.txt | WA | 427 ms | 20788 KB |
test_100-201_ABC.txt | WA | 447 ms | 20788 KB |
test_100-229_ABC.txt | WA | 435 ms | 20656 KB |
test_100-300_ABC.txt | AC | 441 ms | 20656 KB |
test_100-301_ABC.txt | AC | 459 ms | 20792 KB |
test_100-399_ABC.txt | WA | 469 ms | 20656 KB |
test_100-400_ABC.txt | WA | 464 ms | 20804 KB |
test_100-401_ABC.txt | AC | 436 ms | 20784 KB |
test_100-431_ABC.txt | AC | 435 ms | 20656 KB |
test_100-473_ABC.txt | AC | 451 ms | 20632 KB |
test_100-500000_A.txt | AC | 469 ms | 21556 KB |
test_100-500_ABC.txt | AC | 441 ms | 20788 KB |
test_100-7500_AB.txt | AC | 451 ms | 20656 KB |
test_100000-175737_A.txt | AC | 459 ms | 21672 KB |
test_100000-199999_A.txt | AC | 477 ms | 21588 KB |
test_100000-1_A.txt | AC | 455 ms | 20764 KB |
test_100000-200000_A.txt | WA | 445 ms | 21684 KB |
test_100000-200001_A.txt | WA | 448 ms | 21560 KB |
test_100000-300000_A.txt | AC | 479 ms | 21680 KB |
test_100000-300001_A.txt | AC | 476 ms | 21656 KB |
test_100000-321428_A.txt | WA | 468 ms | 21684 KB |
test_100000-383852_A.txt | WA | 466 ms | 21560 KB |
test_100000-399999_A.txt | WA | 480 ms | 21688 KB |
test_100000-400000_A.txt | WA | 470 ms | 21684 KB |
test_100000-400001_A.txt | AC | 469 ms | 21536 KB |
test_100000-461143_A.txt | AC | 464 ms | 21556 KB |
test_100000-482033_A.txt | AC | 482 ms | 21548 KB |
test_100000-500000_A.txt | AC | 478 ms | 21592 KB |
test_100000-500_A.txt | AC | 445 ms | 20788 KB |
test_100000-7500_A.txt | AC | 464 ms | 21044 KB |
test_12376-24751_A.txt | AC | 453 ms | 21044 KB |
test_12376-24752_A.txt | WA | 472 ms | 21300 KB |
test_12376-24753_A.txt | WA | 446 ms | 21176 KB |
test_12376-4187_A.txt | AC | 459 ms | 20944 KB |
test_12376-46199_A.txt | WA | 449 ms | 21560 KB |
test_12376-49503_A.txt | WA | 472 ms | 21556 KB |
test_12376-49504_A.txt | WA | 472 ms | 21556 KB |
test_12376-49505_A.txt | AC | 458 ms | 21556 KB |
test_12376-53158_A.txt | AC | 481 ms | 21428 KB |
test_12376-57785_A.txt | AC | 467 ms | 21556 KB |
test_12376-60441_A.txt | AC | 500 ms | 21476 KB |
test_1500-1_AB.txt | AC | 466 ms | 20788 KB |
test_1500-2999_AB.txt | AC | 446 ms | 20784 KB |
test_1500-3000_AB.txt | WA | 456 ms | 20664 KB |
test_1500-3001_AB.txt | WA | 437 ms | 20664 KB |
test_1500-4072_AB.txt | WA | 446 ms | 20792 KB |
test_1500-477_AB.txt | AC | 444 ms | 20780 KB |
test_1500-500000_A.txt | AC | 476 ms | 21560 KB |
test_1500-500_AB.txt | AC | 460 ms | 20792 KB |
test_1500-5768_AB.txt | WA | 453 ms | 20916 KB |
test_1500-5999_AB.txt | WA | 446 ms | 20916 KB |
test_1500-6000_AB.txt | WA | 462 ms | 20908 KB |
test_1500-6001_AB.txt | AC | 452 ms | 21092 KB |
test_1500-6268_AB.txt | AC | 451 ms | 20972 KB |
test_1500-7024_AB.txt | AC | 469 ms | 20972 KB |
test_1500-7500_AB.txt | AC | 453 ms | 21092 KB |
test_1931-2546_A.txt | AC | 442 ms | 20764 KB |
test_1931-3861_A.txt | AC | 463 ms | 20792 KB |
test_1931-3862_A.txt | WA | 442 ms | 20664 KB |
test_1931-3863_A.txt | WA | 433 ms | 20660 KB |
test_1931-6721_A.txt | WA | 451 ms | 20972 KB |
test_1931-7547_A.txt | WA | 444 ms | 21096 KB |
test_1931-7723_A.txt | WA | 458 ms | 20972 KB |
test_1931-7724_A.txt | WA | 457 ms | 20964 KB |
test_1931-7725_A.txt | AC | 448 ms | 20968 KB |
test_1931-8765_A.txt | AC | 455 ms | 21028 KB |
test_1931-9463_A.txt | AC | 455 ms | 20964 KB |
test_33-106_ABC.txt | WA | 450 ms | 20656 KB |
test_33-131_ABC.txt | WA | 448 ms | 20780 KB |
test_33-132_ABC.txt | WA | 441 ms | 20768 KB |
test_33-133_ABC.txt | AC | 471 ms | 20772 KB |
test_33-134_ABC.txt | AC | 430 ms | 20740 KB |
test_33-146_ABC.txt | AC | 436 ms | 20620 KB |
test_33-51_ABC.txt | AC | 446 ms | 20788 KB |
test_33-65_ABC.txt | AC | 440 ms | 20652 KB |
test_33-66_ABC.txt | WA | 414 ms | 20788 KB |
test_33-67_ABC.txt | WA | 417 ms | 20652 KB |
test_33-71_ABC.txt | WA | 432 ms | 20652 KB |
test_578-114_AB.txt | AC | 449 ms | 20788 KB |
test_578-1155_AB.txt | AC | 447 ms | 20780 KB |
test_578-1156_AB.txt | WA | 446 ms | 20660 KB |
test_578-1157_AB.txt | WA | 433 ms | 20660 KB |
test_578-1984_AB.txt | WA | 451 ms | 20788 KB |
test_578-2101_AB.txt | WA | 428 ms | 20656 KB |
test_578-2230_AB.txt | WA | 450 ms | 20652 KB |
test_578-2311_AB.txt | WA | 449 ms | 20664 KB |
test_578-2312_AB.txt | WA | 461 ms | 20728 KB |
test_578-2313_AB.txt | AC | 442 ms | 20780 KB |
test_578-2728_AB.txt | AC | 437 ms | 20664 KB |
test_84391-168781_A.txt | AC | 468 ms | 21556 KB |
test_84391-168782_A.txt | WA | 493 ms | 21556 KB |
test_84391-168783_A.txt | WA | 480 ms | 21524 KB |
test_84391-263979_A.txt | WA | 439 ms | 21588 KB |
test_84391-294799_A.txt | WA | 477 ms | 21432 KB |
test_84391-337563_A.txt | WA | 470 ms | 21552 KB |
test_84391-337564_A.txt | WA | 488 ms | 21552 KB |
test_84391-337565_A.txt | AC | 433 ms | 21416 KB |
test_84391-407535_A.txt | AC | 433 ms | 21556 KB |
test_84391-420642_A.txt | AC | 438 ms | 21684 KB |
test_84391-98907_A.txt | AC | 433 ms | 21552 KB |
test_92-183_ABC.txt | AC | 421 ms | 20648 KB |
test_92-184_ABC.txt | WA | 418 ms | 20656 KB |
test_92-185_ABC.txt | WA | 419 ms | 20652 KB |
test_92-310_ABC.txt | WA | 413 ms | 20784 KB |
test_92-34_ABC.txt | AC | 416 ms | 20788 KB |
test_92-367_ABC.txt | WA | 416 ms | 20784 KB |
test_92-368_ABC.txt | WA | 417 ms | 20784 KB |
test_92-369_ABC.txt | AC | 413 ms | 20656 KB |
test_92-391_ABC.txt | AC | 414 ms | 20788 KB |
test_92-434_ABC.txt | AC | 419 ms | 20752 KB |
test_92-459_ABC.txt | AC | 414 ms | 20664 KB |