結果
問題 |
No.3241 Make Multiplication of 8
|
ユーザー |
![]() |
提出日時 | 2025-08-22 21:52:53 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 773 ms / 2,000 ms |
コード長 | 704 bytes |
コンパイル時間 | 3,371 ms |
コンパイル使用メモリ | 81,284 KB |
実行使用メモリ | 58,356 KB |
最終ジャッジ日時 | 2025-08-22 21:53:13 |
合計ジャッジ時間 | 17,530 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 23 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; int[] b = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); b[i] = sc.nextInt(); } sc.close(); long[] cnt = new long[4]; for (int i = 0; i < n; i++) { int ai = a[i]; for (int j = 0; j < 4; j++) { if (ai % 2 != 0 || j == 3) { cnt[j] += b[i]; break; } ai /= 2; } } long ans = cnt[3]; long min = Math.min(cnt[2], cnt[1]); ans += min; cnt[2] -= min; cnt[1] -= min; ans += cnt[2] / 2; ans += cnt[1] / 3; System.out.println(ans); } }