ITGUY17 - Editorial

Problem: https://www.codechef.com/PBK12020/problems/ITGUY17

DIFFICULTY:

EASY.

PROBLEM:

Chef has N laddus of K sweetness each. Chef wants to eat all laddus, but Chef is restricted with the given condition that he must not eat two adjacent laddus. Chef starts calculating the maximum sweetness that he will get from the laddus. Find the maximum sweetness that chef gets at the end of all calculations.

Program:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

ios::sync_with_stdio(false);
cin.tie(NULL);
ll t,n,k;
cin >> t;
while (t--) {
    cin >> n >> k;
    if (n % 2 == 0) {
        cout << (n / 2) * k << "\n";
    }
    else {
        cout << (n / 2 + 1) * k << "\n";
    }
}
return 0;
}
1 Like

Will there be a push_back(2)??

1 Like

I like the response given by the CodeChef Community to this push_back(i) series.
I would love to host push_back(2) as well.
Thanks and Regards

6 Likes

It was a great contest with some good problems.
Looking forward to see more contests in this series.
UPD - I think, it is the fastest editorial ever of an unrated contest on CodeChef.

1 Like