結果
問題 |
No.158 奇妙なお使い
|
ユーザー |
![]() |
提出日時 | 2020-05-14 14:48:44 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 960 bytes |
コンパイル時間 | 2,305 ms |
コンパイル使用メモリ | 76,608 KB |
実行使用メモリ | 48,504 KB |
最終ジャッジ日時 | 2024-09-15 06:55:28 |
合計ジャッジ時間 | 9,698 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 4 |
other | AC * 4 TLE * 1 -- * 22 |
ソースコード
import java.util.*; public class Main { static int[] aArr = new int[4]; static int[] bArr = new int[4]; public static void main (String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); for (int i = 0; i < 4; i++) { aArr[i] = sc.nextInt(); } for (int i = 0; i < 4; i++) { bArr[i] = sc.nextInt(); } System.out.println(func(a, b, c)); } static int func(int a, int b, int c) { return Math.max(func(a, b, c, aArr), func(a, b, c, bArr)); } static int func(int a, int b, int c, int[] arr) { if (a * 1000 + b * 100 + c < arr[0]) { return 0; } int x = arr[0]; while (x >= 1000 && a > 0) { x -= 1000; a--; } while (x >= 100 && b > 0) { x -= 100; b--; } c -= x; if (c < 0) { return 0; } return func(a + arr[1], b + arr[2], c + arr[3]) + 1; } }