Submission #229781
Source Code Expand
import java.util.Arrays; import java.util.Scanner; public class Main { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); final int MOD = 1000000007; int[] dx = { 1, 0, 0, -1 }; int[] dy = { 0, 1, -1, 0 }; void run() { int n = sc.nextInt(); int X = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } int sum = 0; for (int i = 0; i < n; i++) { if (( 1 << i & X) != 0) { sum += a[i]; } } System.out.println(sum); } public static void main(String[] args) { new Main().run(); } void debug(Object... o) { System.out.println(Arrays.deepToString(o)); } void debug2(int[][] array) { for (int i = 0; i < array.length; i++) { for (int j = 0; j < array[i].length; j++) { System.out.print(array[i][j]); } System.out.println(); } } class MyScanner { int nextInt() { try { int c = System.in.read(); while (c != '-' && (c < '0' || '9' < c)) c = System.in.read(); if (c == '-') return -nextInt(); int res = 0; do { res *= 10; res += c - '0'; c = System.in.read(); } while ('0' <= c && c <= '9'); return res; } catch (Exception e) { return -1; } } double nextDouble() { return Double.parseDouble(next()); } long nextLong() { return Long.parseLong(next()); } String next() { try { StringBuilder res = new StringBuilder(""); int c = System.in.read(); while (Character.isWhitespace(c)) c = System.in.read(); do { res.append((char) c); } while (!Character.isWhitespace(c = System.in.read())); return res.toString(); } catch (Exception e) { return null; } } } }
Submission Info
Submission Time | |
---|---|
Task | B - 価格の合計 |
User | suigingin |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 1795 Byte |
Status | AC |
Exec Time | 378 ms |
Memory | 23032 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 | 340 ms | 22964 KB |
subtask0_sample02.txt | AC | 354 ms | 22960 KB |
subtask0_sample03.txt | AC | 337 ms | 22884 KB |
subtask1_01.txt | AC | 346 ms | 22956 KB |
subtask1_02.txt | AC | 331 ms | 22908 KB |
subtask1_03.txt | AC | 326 ms | 22904 KB |
subtask1_04.txt | AC | 344 ms | 22956 KB |
subtask1_05.txt | AC | 329 ms | 22920 KB |
subtask1_06.txt | AC | 330 ms | 22912 KB |
subtask1_07.txt | AC | 361 ms | 23032 KB |
subtask1_08.txt | AC | 378 ms | 22928 KB |
subtask1_09.txt | AC | 378 ms | 22940 KB |
subtask1_10.txt | AC | 358 ms | 22928 KB |
subtask1_11.txt | AC | 339 ms | 22968 KB |
subtask1_12.txt | AC | 334 ms | 22964 KB |
subtask1_13.txt | AC | 344 ms | 22964 KB |
subtask1_14.txt | AC | 340 ms | 22912 KB |
subtask1_15.txt | AC | 334 ms | 22916 KB |
subtask1_16.txt | AC | 338 ms | 22976 KB |
subtask1_17.txt | AC | 357 ms | 22924 KB |