-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDIV03.cpp
More file actions
38 lines (38 loc) · 728 Bytes
/
DIV03.cpp
File metadata and controls
38 lines (38 loc) · 728 Bytes
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
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int a[10],sum;
for(int i=0;i<10;i++)
{
cin>>a[i];
}
cin>>sum;
if(sum!=0)
{
int j=9;
while(sum!=0 && j>=0)
{
if(a[j]<=sum)
{
sum-=a[j];
a[j]=0;
}
j--;
}
}
for(int k=9;k>=0;k--)
{
if(a[k]!=0)
{
cout<<k+1<<endl;
break;
}
}
}
return 0;
}