# Why i am unable to get a full marks in the program from june challenge

question url =https://www.codechef.com/problems/CHFICRM
why am i not getting full marks through the above solution`Preformatted text`

same with this solution of mine.And i canâ€™t figure out what is the fault
https://www.codechef.com/viewsolution/34430723

yes exactly i am unable to figure it out .

hi

i made the same mistake the first time i submitted this
The problem is that you have taken a single array to store all coins
Instead, make three variables for the three different types of coins

1 Like

i code in PYTH 3.6, so really sorry if i made a mistake in understanding your approach

hereâ€™s my sol:
check this out

i hope its simple enough to be translated easily to your language
feel free to ask again if you donâ€™t understand my approach

1 Like

also, check out the editorial

1 Like

thank you i understood your approach but still unable to get the answer that y my code was not accepted

https://www.codechef.com/viewsolution/33935485

You can check out my solution in C.
Or can see the editorial.

1 Like

in case of coin of 15 is given :
you should first give 10 if you have
I HAVE MADE SOME CHANGES IN YOUR PROGRAM now it is working
https://www.codechef.com/viewsolution/34446353

1 Like

in my solutionâ€¦i have commented the wrong approach i had used earlier.
For certain testcases, the code goes wrong
earlier i used chef_money = 0 for the total money chef has and it gave WA

my logic turned out to be wrong
for everytime, i did not subtract the change from the total money chef has

Yep, me too. The question was about to keep the no of coins. but I was keeping the total of change in a single variable.

1 Like

there must be a logical error where you are not adding/subtracting in the right places.

if a[i] = 5
+= 5
if a[i] = 10
+= 10
-= 5
if a[i] = 15
+=15
-=10 or -= (5+5)

i think this part is wrong

you are doing -15 for 15 value coin instead of -10
A person must pay 5 for an icecream, so if coin value > 5, chef returns coin value - 5

did you get it?

1 Like

For the case of coin valued 15, you need to empty up 10â€™s coin first and then use up 5â€™s coin.

As per your code logic you are checking which coin is valued more and you are using that, which shouldnâ€™t be the case.
Example case : 5 10 5 5 5 15 10 10

2 Likes

In case of 15 why are you giving him 15 back? @anon92172001

2 Likes

yeahâ€¦that gave me WA earlier

yes, he should give coin value - 5, so his logic is wrong

1 Like

And Here is the Code:
#include<bits/stdc++.h>
//#include
using namespace std;

typedef long long ll;
typedef int ii;
typedef vector vi;

#define T while(tâ€“)
#define for1(i,a,b) for(i=a;i<=b;i++)
#define pb push_back
//#define mp make_pair

ii main()
{

``````ii t,n,i; cin>>t;

while(t--)
{

cin>>n; ii numbers[10005]={}; vi v;

for1(i,0,n-1)
{

cin>>numbers[i];
v.pb(numbers[i]);

}

multiset<ii> chef;

for1(i,0,n-1)
{

if(v[i]==5) chef.insert(5);
else if(v[i]==10 && chef.count(5)>0)
{

chef.insert(10); chef.erase(chef.find(5));

}
else if(v[i]==15 && chef.count(10)>0)
{

chef.insert(15); chef.erase(chef.find(10));

}
else if(v[i]==15 && chef.count(5)>1)
{

chef.insert(15); chef.erase(chef.find(5)); chef.erase(chef.find(5));
}
else
{
break;
}

}

if(i==n) cout<<"YES"<<"\n";
else cout<<"NO"<<"\n";

v.clear(); chef.clear();

}
``````

}

Yup.

Here is my solution to this problem.
https://www.codechef.com/viewsolution/33663941