-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAmr and Music.cpp
72 lines (71 loc) · 1.32 KB
/
Amr and Music.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define pf printf
#define sf scanf
#define MAX 105
int a[MAX], b[MAX], print[MAX];
int main()
{
int n, k, i, p;
int sum, count;
sf("%d%d", &n, &k);
int j=1;
for(i=1; i<=n; i++)
{
sf("%d", &a[i]);
b[j] = a[i];
j++;
}
sort(a, a+i);
if(a[1]>k)
{
pf("0\n");
}
else
{
sum =0;
count = 0;
for(int i=1 ;i<=n; i++)
{
sum = sum + a[i];
count ++;
if(sum>=k)
{
if(sum==k)
{
break;
}
else
{
sum = sum - a[i];
count --;
break;
}
}
}
p = 1;
for(int i=1; i<=count; i++)
{
for(int j=1; j<=n ;j++)
{
if(a[i]==b[j])
{
print[p] = j;
b[j] = 0;
p++;
}
}
}
sort(print, print+p);
pf("%d\n", count);
for(p=1; p<=count; p++)
{
pf("%d ", print[p]);
}
pf("\n");
}
}