#1. Today, a shop offers a very good deal “Buy 3 only pay 2” with a rule that in one bill only the cheapest
ones get free. Your job is to help shopper find the maximum discount he can get.
Example:
- Your friend wants to buy 7 items, costing $350000, $400000, $300000, $100000, $150000, $200000, and $250000.
- If he buys all items in one bill, he gets 2 free items which are the cheapest ones of $100000 and $150000. Consequently, he gets the discount of $250000 and must pay $1500000.
- If he buys the items separately, he may get a bigger discount. For instance, he separates the items in three bills as follow:
o The first bills: 3 items $400000, $300000, and $250000 -> $250000 discount.
o The second bill: 3 items $350000, $200000 and $100000 -> $100000 discount.
o The third bill: 1 item $150000 -> no discount.
o Eventually, he gets the total discount of $350000 and must pay $1400000.
Input is read from the text file [login to view URL] consisting of:
- The first line is the number of items he buys
- The second line is the list of prices of items
Output is written to the text file [login to view URL] consisting of ONLY ONE NUMBER which is
the maximum discount he can get.
[Example]:
[login to view URL] [login to view URL]
6
100000 400000 200000 350000 300000 250000 400000
Limitation:
- 1 ≤ number of items he buys ≤ 200000
- 1 ≤ the cost of an item ≤ 1000000
- Processing time of the proposed algorithm ≤ 1 second
The output file only has one value
- The main function must follow the template:
int main(int argc, const char* argv[])
{
//content
…
return 0;
}
- The extension of the input file of the programming problem is “inp” (ex:[login to view URL]), NOT “[login to view URL]” (ex: [login to view URL])
- Sample code for writing to a text file:
#include <stdio.h>
int main()
{
int num;
FILE *fptr;
fptr = fopen("[login to view URL]","w");
printf("Enter num: ");
scanf("%d",&num);
fprintf(fptr,"%d",num);
fclose(fptr);
return 0;
}
Hi!
I'm interesting your project very well.
I am mastering c++ and I'm a good Mathematician.
And also I have many experience and good skill about Algorithm.
Let's go ahead with me
I have high proficiency in Matlab including SPSS Statistics, Simulation, Mathematics, Python,Algorithm, C++ programming, Machine learning and Statistics analysis. Once you share the project, I will have a look & confirm if I can do it.
I’m honest, creative and a unique person to carry out your tasks given to me. Leaving your project on our hand is a privileged; we'll make sure that the project is done in a perfect way and do our best until you satisfied.
I would love to discuss this project with you and meet your exact requirements. I am confident I can provide you with top notch materials that will fit your needs. I'm proud my work on being professional, of the highest quality and always delivered on time
I, Jignesh Lakhani completed my masters from IIT Roorkee in Computer Engineering. I am having very good knowledge of C, C++, Java, JavaFX, Algorithm and Data Structure. I am having strong analytical power. I will complete your project before the deadline.
I am looking forward to discussing with you about this job post. Please feel free to contact me.
Respectfully,
Jignesh
Sir,
you need help in C programming?
like mentioned ?
so you don't need to be worry because I am here with outstanding understanding of programmin in C
I'll provide you 100% quality work with money back guarantee
I hope I'll get this project sokn to show you my skills
thanks
Call me a Hacker (white hat), a guru or whatever suits you best. The fact is by hiring me YOU'RE GOING TO GET A GREAT JOB DONE AND HAVE IT DELIVERED QUICKER THAN AS QUICK AS POSSIBLE!
I have a long road behind me paved by code written in C, Java, Swift, PHP, JavaScript etc.
I have successfully delivered software for the most relevant platforms out there: iOS, Android, Web and Desktop.
My code is clean and my systems are very well designed.
Programers love my code and customers love my software.
Because of all the above you can call me simply:
"The Ultimate Software Developer".
I'm a systems engineering student. I've resolved many problems like this one
Relevant Skills and Experience
C and C++ handling, resolved many programming problems like this