Editorial for CCC '15 J1 - Special Day


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.

Author: Phoenix1369

The problem is asking you to identify the relative position of the given date to February 18th.

Remember when making comparisons to take the month into consideration before the day.

Time Complexity: \mathcal{O}(1)

Solution — C++

#include <bits/stdc++.h>

using namespace std;

string junior1(int month, int day)
{
    if(month <= 2)
    {
        if(month == 1 || day < 18)
            return "Before";
        if(day == 18)
            return "Special";
    }
    return "After";
}

int main()
{
    int m, d;
    scanf("%d\n%d", &m, &d);
    cout << junior1(m, d) << endl;
    return 0;
}

Comments

There are no comments at the moment.