SKFA Problem

Unless one is wealthy there is no use in being a charming fellow. Romance is the privilege of the rich, not the profession of the unemployed. These are the great truths of modern life which Hughie Erskine never realised. Poor Hughie! Intellectually, we must admit, he was not of much importance. He never said a brilliant or even an ill-natured thing in his life. But then he was wonderfully good- looking, with his crisp brown hair, his clear-cut profile, and his grey eyes. He was as popular with men as he was with women and he had every accomplishment, except that of making money. He tried everything. He had been a tea merchant for a little longer, but had soon tired of pekoe and souchong. Then he had tried selling dry sherry. That did not answer: the sherry was a little too dry. Now, he started a flowristry. He grows only Orchids and Azaleas. He wants to display these flowers in a straight line in his shop. He decided to arrange the flowers in order to minimize the SKFA. The SKFA (same kind of flower arragement) is the maximum number of flowers of the same kind (all Orchids or all Azaleas) that appear consecutively. Given O (Number of Orchids) and A (Number of Azaleas), He needs your help to calculate the minimum SKFA among all possible arrangements.

Input Format:

First line contains a single interger ‘T’ representing number of test cases. Next T lines contains, two space seperated intergers O and A.

Output Format:

Output a single integer representing the minimum SKFA.

#include <iostream>
using namespace std;

int main() {
    int t;
    cin >> t; // read the number of test cases
    for (int i = 0; i < t; i++) {
        int o, a;
        cin >> o >> a; // read the number of orchids and azaleas
        int minSKFA = min(o, a) * 2 + 1; // calculate the minimum SKFA
        cout << minSKFA << endl; // output the result
    }
return 0;
}
Share your love
Saransh Saurav

Saransh Saurav

Articles: 68

Leave a Reply

Your email address will not be published. Required fields are marked *