Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

Codechef Starters 246 (Div 4) - Unofficial Editorial for problems 1 - 3
Difference between en1 and en2, changed 27 character(s)
**Problem 1. Point Calculation (POINTCAL)**↵

<spoiler summary="Explanation">↵
In this problem, you just need a simple math formula that is just given inside the problem statement. Thus the formula:↵
$a*3 + b * 1 + c * 0$↵
</spoiler>↵


<spoiler summary="Code">↵
```↵
#include <bits/stdc++.h>↵
using namespace std;↵

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);↵
#define endl "\n"↵

int main() {↵
    fastio;↵
    int a, b, c; cin >> a >> b >> c;↵
    cout << (a * 3 + b) << endl; // because C cancels out and b * 1 is b.↵
}↵
```↵
</spoiler>↵

**Problem 2. Plant (TEMPPLANT)**↵

<spoiler summary="Explanation">↵
In this problem, we need to keep track of the adjacent elements in the array and find the smallest in them. And now, we want the max possible height so, the answer is $maximum = max(maximum, min(a[i], a[i + 1]))$↵
</spoiler>↵


<spoiler summary="Code">↵
```↵
#include <bits/stdc++.h>↵
using namespace std;↵

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);↵
#define endl "\n"↵

int main() {↵
    fastio;↵
    int t; cin >> t;↵
    while(t--){↵
        int n; cin >> n; ↵
        vector<int> a(n);↵
        for(int i = 0; i<n;i++) cin >> a[i];↵
        int maxh = 0;↵
        for(int i = 0; i < n-1; i++){↵
            int curr = min(a[i], a[i + 1]); // keeping track of adjacent elements↵
            maxh = max(curr, maxh);↵
        }↵
        cout << maxh << endl;↵
    }↵
}↵

```↵
</spoiler>↵

**Problem 3. Red Yellow Cards (RYCARDS)**↵

<spoiler summary="Explanation">↵
So, In this problem, each red card results in the footballer begin sent off so at min $R$ send offs.↵
We have to minimize this no. of send offs. Each red card can free 1 yellow card up.↵
So we can cancel out upto R yellow cards in the order $(yellow, red, yellow, red, yellow, red, …)$↵

So assume Y = yellow, R = red.↵
if Y is lesser than equal to R.↵
in this case, we'll be able to cancel out all of the yellow cards.↵
So, min total no. of send-offs will equal exactly R, R &mdash; one from each red card.↵

The outcome of this will result in the formula:↵

$R + \dfrac{\max(0, y - r)}{2}$ for any testcase.↵
</spoiler>↵


<spoiler summary="Code">↵
```↵
#include <bits/stdc++.h>↵
using namespace std;↵

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);↵
#define endl "\n"↵

int main() {↵
    fastio;↵
    int t; cin >> t;↵
    while(t--){↵
        int r, y; cin >> r >> y;↵
        cout << r + (max(0, y - r) / 2) << endl;↵
    }↵
}↵

```↵
</spoiler>↵

Shoutouts to:↵

Contest Admin, Statement Verifier and Setter: Shreyan [user:Dominater069,2026-07-08] Ray<br>↵
Tester : Nishank [user:IceKnight1093,2026-07-08] Suresh<br>↵
Text Editorialist 
(Codechef): Nishank [user:IceKnight1093,2026-07-08] Suresh

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English techgodprogrammer 2026-07-09 09:24:52 2
en2 English techgodprogrammer 2026-07-09 05:00:58 27 Tiny change: 'torialist : Nishank ' -> 'torialist (Codechef): Nishank '
en1 English techgodprogrammer 2026-07-08 20:56:49 2812 Initial revision (published)