Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module xxx;
- import std.stdio, std.bigint, std.conv, std.array, std.string, std.algorithm, std.typecons;
- void main() {
- auto aa = readln().strip().split();
- auto n = to!int(aa[0]);
- auto s = BigInt(aa[1]);
- Tuple!(BigInt, string)[] m;
- for (int i = 0; i < n; i++) {
- auto a = readln().strip().split();
- auto name = a[0];
- auto num = BigInt(a[1]);
- m ~= tuple(num, name);
- }
- m.sort();
- string[] r;
- foreach_reverse(t; m) {
- if (s >= t[0]) {
- r ~= t[1];
- s -= t[0];
- }
- }
- if (s == 0) {
- writeln(r.length);
- foreach(name; r) {
- writeln(name);
- }
- } else {
- writeln(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement