Submission #229784
Source Code Expand
import java.io.*; import java.util.*; public class Main { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); public void run() { int n = in.nextInt(); int X = in.nextInt(); int[] a = in.nextIntArray(n); int res = 0; for (int i = 0; i < n; i++) { int b = X % 2; if (b == 1) res += a[i]; X /= 2; } System.out.println(res); out.close(); } public static void main(String[] args) { new Main().run(); } public void mapDebug(int[][] a) { System.out.println("--------map display---------"); for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i].length; j++) { System.out.printf("%3d ", a[i][j]); } System.out.println(); } System.out.println("----------------------------"); System.out.println(); } public void debug(Object... obj) { System.out.println(Arrays.deepToString(obj)); } class FastScanner { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; public FastScanner(InputStream stream) { this.stream = stream; //stream = new FileInputStream(new File("dec.in")); } int read() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } boolean isEndline(int c) { return c == '\n' || c == '\r' || c == -1; } int nextInt() { return Integer.parseInt(next()); } int[] nextIntArray(int n) { int[] array = new int[n]; for (int i = 0; i < n; i++) array[i] = nextInt(); return array; } long nextLong() { return Long.parseLong(next()); } long[] nextLongArray(int n) { long[] array = new long[n]; for (int i = 0; i < n; i++) array[i] = nextLong(); return array; } double nextDouble() { return Double.parseDouble(next()); } double[] nextDoubleArray(int n) { double[] array = new double[n]; for (int i = 0; i < n; i++) array[i] = nextDouble(); return array; } String next() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } String[] nextStringArray(int n) { String[] array = new String[n]; for (int i = 0; i < n; i++) array[i] = next(); return array; } String nextLine() { int c = read(); while (isEndline(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isEndline(c)); return res.toString(); } } }
Submission Info
Submission Time | |
---|---|
Task | B - 価格の合計 |
User | hiro116s |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 3082 Byte |
Status | AC |
Exec Time | 314 ms |
Memory | 20744 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | subtask0_sample01.txt, subtask0_sample02.txt, subtask0_sample03.txt |
All | subtask0_sample01.txt, subtask0_sample02.txt, subtask0_sample03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
subtask0_sample01.txt | AC | 303 ms | 20584 KB |
subtask0_sample02.txt | AC | 302 ms | 20680 KB |
subtask0_sample03.txt | AC | 311 ms | 20612 KB |
subtask1_01.txt | AC | 311 ms | 20588 KB |
subtask1_02.txt | AC | 307 ms | 20580 KB |
subtask1_03.txt | AC | 310 ms | 20744 KB |
subtask1_04.txt | AC | 302 ms | 20728 KB |
subtask1_05.txt | AC | 301 ms | 20616 KB |
subtask1_06.txt | AC | 306 ms | 20616 KB |
subtask1_07.txt | AC | 302 ms | 20588 KB |
subtask1_08.txt | AC | 314 ms | 20616 KB |
subtask1_09.txt | AC | 303 ms | 20588 KB |
subtask1_10.txt | AC | 309 ms | 20588 KB |
subtask1_11.txt | AC | 301 ms | 20656 KB |
subtask1_12.txt | AC | 305 ms | 20616 KB |
subtask1_13.txt | AC | 308 ms | 20676 KB |
subtask1_14.txt | AC | 309 ms | 20640 KB |
subtask1_15.txt | AC | 303 ms | 20636 KB |
subtask1_16.txt | AC | 304 ms | 20612 KB |
subtask1_17.txt | AC | 313 ms | 20656 KB |