結果
問題 | No.1015 おつりは要らないです |
ユーザー | ntk3264 |
提出日時 | 2020-04-04 17:31:38 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 778 ms / 2,000 ms |
コード長 | 2,070 bytes |
コンパイル時間 | 2,439 ms |
コンパイル使用メモリ | 77,328 KB |
実行使用メモリ | 49,672 KB |
最終ジャッジ日時 | 2024-04-29 05:07:35 |
合計ジャッジ時間 | 22,739 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 131 ms
41,536 KB |
testcase_01 | AC | 120 ms
40,284 KB |
testcase_02 | AC | 120 ms
40,552 KB |
testcase_03 | AC | 128 ms
41,472 KB |
testcase_04 | AC | 132 ms
41,492 KB |
testcase_05 | AC | 117 ms
40,232 KB |
testcase_06 | AC | 135 ms
41,044 KB |
testcase_07 | AC | 134 ms
41,436 KB |
testcase_08 | AC | 134 ms
41,240 KB |
testcase_09 | AC | 131 ms
41,256 KB |
testcase_10 | AC | 743 ms
48,748 KB |
testcase_11 | AC | 731 ms
49,480 KB |
testcase_12 | AC | 741 ms
48,932 KB |
testcase_13 | AC | 742 ms
49,072 KB |
testcase_14 | AC | 778 ms
49,100 KB |
testcase_15 | AC | 737 ms
48,784 KB |
testcase_16 | AC | 717 ms
49,116 KB |
testcase_17 | AC | 719 ms
49,000 KB |
testcase_18 | AC | 771 ms
48,996 KB |
testcase_19 | AC | 754 ms
48,976 KB |
testcase_20 | AC | 617 ms
49,576 KB |
testcase_21 | AC | 719 ms
49,184 KB |
testcase_22 | AC | 713 ms
48,908 KB |
testcase_23 | AC | 718 ms
48,820 KB |
testcase_24 | AC | 715 ms
48,992 KB |
testcase_25 | AC | 727 ms
49,036 KB |
testcase_26 | AC | 727 ms
48,928 KB |
testcase_27 | AC | 770 ms
49,304 KB |
testcase_28 | AC | 712 ms
48,844 KB |
testcase_29 | AC | 742 ms
48,916 KB |
testcase_30 | AC | 134 ms
41,364 KB |
testcase_31 | AC | 568 ms
48,728 KB |
testcase_32 | AC | 569 ms
48,532 KB |
testcase_33 | AC | 654 ms
49,672 KB |
testcase_34 | AC | 134 ms
41,464 KB |
testcase_35 | AC | 119 ms
40,180 KB |
testcase_36 | AC | 132 ms
41,144 KB |
ソースコード
import java.util.*; public class Main { Scanner sc = new Scanner(System.in); public static void main(String[] args) { new Main().run(); } void run() { int n = sc.nextInt(); long x = sc.nextLong(); long y = sc.nextLong(); long z = sc.nextLong(); long[] arr = new long[n]; for (int i=0; i<n; i++) arr[i] = sc.nextLong(); int max = 0; label: for (int i=0; i<n; i++) { if (z==0) break label; if (arr[i]>=10000) { long cnt = arr[i]/10000; if (z<cnt) cnt = z; z -= cnt; arr[i] -= cnt*10000; } } Arrays.sort(arr); if (z>0) { label: for (int i=n-1; i>=0; i--) { arr[i] -= 10000; z--; if (z==0) break label; } } label: for (int i=0; i<n; i++) { if (y==0) break label; if (arr[i]>=5000) { long cnt = arr[i]/5000; if (y<cnt) cnt = y; y -= cnt; arr[i] -= cnt*5000; } } Arrays.sort(arr); if (y>0) { label: for (int i=n-1; i>=0; i--) { arr[i] -= 5000; y--; if (y==0) break label; } } label: for (int i=0; i<n; i++) { if (x==0) break label; if (arr[i]>=0) { long cnt = (arr[i]/1000)+1; if (x<cnt) cnt = x; x -= cnt; arr[i] -= cnt*1000; } } int cnt = 0; for (int i=0; i<n; i++) { if (arr[i]<0) cnt++; } // for (int i=0; i<n; i++) { // System.out.println(arr[i]); // } // System.out.println("cnt" +cnt); if (cnt==n) { System.out.print("Yes"); } else { System.out.print("No"); } } }