phanindhar1

ylee

Nov 19th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. private static void CashBack(int total, int minItem, int cashback, int[] pricelist)
  2. {
  3. Array.Sort(pricelist);
  4.  
  5. Func<int, int, int, int[], int> bill = delegate (int n, int m, int c, int[] list)
  6. {
  7. int sum = 0;
  8. for (int i = 0; i < n; i++)
  9. {
  10. sum += list[i];
  11. }
  12.  
  13. if (n >= 5) sum -= 10;
  14. if (n >= m) sum -= (n / m) * c;
  15.  
  16. return sum;
  17. };
  18.  
  19. int curBill = 0, max = -1,left =total;
  20.  
  21. for (int i = 0; i < pricelist.Length; i++)
  22. {
  23. curBill = bill(i, minItem, cashback, pricelist);
  24. if(curBill < total )
  25. {
  26. left = total - curBill;
  27. max = i;
  28. }
  29. }
  30. Console.WriteLine(left+" "+max);
  31.  
  32. return;
  33. }
Add Comment
Please, Sign In to add comment