507A.md (1655B)
1 Source: https://codeforces.com/problemset/problem/507/A 2 3 A. Amr and Music 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. 22 23 Amr has *n* instruments, it takes *a**i* days to learn *i*-th instrument. Being busy, Amr dedicated *k* days to learn how to play the maximum possible number of instruments. 24 25 Amr asked for your help to distribute his free days between instruments so that he can achieve his goal. 26 27 Input 28 29 The first line contains two numbers *n*, *k* (1 ≤ *n* ≤ 100, 0 ≤ *k* ≤ 10 000), the number of instruments and number of days respectively. 30 31 The second line contains *n* integers *a**i* (1 ≤ *a**i* ≤ 100), representing number of days required to learn the *i*-th instrument. 32 33 Output 34 35 In the first line output one integer *m* representing the maximum number of instruments Amr can learn. 36 37 In the second line output *m* space-separated integers: the indices of instruments to be learnt. You may output indices in any order. 38 39 if there are multiple optimal solutions output any. It is not necessary to use all days for studying. 40 41 Examples 42 43 Input 44 45 ``` 46 4 10 47 4 3 1 2 48 ``` 49 50 Output 51 52 ``` 53 4 54 1 2 3 4 55 ``` 56 57 Input 58 59 ``` 60 5 6 61 4 3 1 1 2 62 ``` 63 64 Output 65 66 ``` 67 3 68 1 3 4 69 ``` 70 71 Input 72 73 ``` 74 1 3 75 4 76 ``` 77 78 Output 79 80 ``` 81 0 82 ``` 83 84 Note 85 86 In the first test Amr can learn all 4 instruments. 87 88 In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}. 89 90 In the third test Amr doesn't have enough time to learn the only presented instrument.