+ 1
Please guys solve these two codeforces problem , I just stuck here. And comment your code at the comment box at bottom of blog
https://ccodeforces.blogspot.com/2020/01/codeforces-problems.html?m=1 https://ccodeforces.blogspot.com/2020/01/codeforces-problem.html?m=1
2 odpowiedzi
+ 3
Where do you need help?
First task:
8 2 1 9 5 -> 6 4 7 2 3
8 -> 7 -> 6 //2
2 -> 3 -> 4 //2
1 -> 0 -> 9 -> 8 -> 7 //4
9 -> 0 -> 1 -> 2 //3
5 -> 4 -> 3 //2
Output: 13
You only need to decide which distance is smaller.
8 -> 7 -> 6 vs 8 -> 9 -> 0 -> 1 ... -> 6
Second task:
n = 6, m = 2, a = 1, b = 2
n rides / m
6/2 = 3 -> you need 3 m ride tickets
3 m ride tickets * b = 6
You can also buy 6 tickets for 1
6 * 1 = 6
n = 5, m = 2, a = 2, b = 3
5/m = 2
Buy 2 m ride tickets * b = 6
Buy 1 ride * a = 2
-> cost: 8
Buying only normal tickets would cost 5 * 2 = 10
Output: 8
+ 1
Thanks bro