結果
問題 |
No.1015 おつりは要らないです
|
ユーザー |
![]() |
提出日時 | 2020-05-13 16:50:35 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 979 ms / 2,000 ms |
コード長 | 1,345 bytes |
コンパイル時間 | 2,700 ms |
コンパイル使用メモリ | 78,372 KB |
実行使用メモリ | 71,308 KB |
最終ジャッジ日時 | 2024-11-18 07:22:10 |
合計ジャッジ時間 | 26,643 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int sen = sc.nextInt(); int gosen = sc.nextInt(); int man = sc.nextInt(); PriorityQueue<Integer> queue = new PriorityQueue<Integer>(new Comparator<Integer>() { public int compare(Integer i1, Integer i2) { return i2.intValue() - i1.intValue(); } }); for (int i = 0; i < n; i++) { queue.add(sc.nextInt()); } while (man > 0 && queue.size() > 0) { int x = queue.poll(); if (x < 10000) { man--; } else if (x / 10000 >= man) { queue.add(x - man * 10000); man = 0; } else { int count = x / 10000; man -= count; queue.add(x % 10000); } } while (gosen > 0 && queue.size() > 0) { int x = queue.poll(); if (x < 5000) { gosen--; } else if (x / 5000 >= gosen) { queue.add(x - gosen * 5000); gosen = 0; } else { int count = x / 5000; gosen -= count; queue.add(x % 5000); } } while (queue.size() > 0 && sen >= 0) { int x = queue.poll(); sen -= (x + 1000) / 1000; } if (sen < 0) { System.out.println("No"); } else { System.out.println("Yes"); } } }