INTRVS - Editorial

PROBLEM LINK:

Practice
Div-2 Contest
Div-1 Contest

Author: Smit Mandavia
Tester: Rahul Dugar
Editorialist: Mohammed Ehab

DIFFICULTY:

CAKEWALK

PREREQUISITES:

None

PROBLEM:

A candidate is doing an interview. He was given N problems, and you know how much time he took for each problem, or that he didn’t solve it. If he solved less than half the problems, he’s rejected. Otherwise, if he solved one of the problems in more than K seconds, he’s too slow. If he solved all the problems, and in at most 1 second each, he’s a bot. If none of that happens, he’s accepted. Determine which one he is.

SOLUTIONS:

Editorialist's Solution
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    while (t--)
    {
        int n,k;
        scanf("%d%d",&n,&k);
        int cnt=0,mx=0; //number of problems solved and max time among solved problems
        bool bot=1;
        for (int i=0;i<n;i++)
        {
            int a;
            scanf("%d",&a);
            if (a!=-1)
            {
                cnt++;
                mx=max(mx,a);
                bot&=(a<=1);
            }
            else
            bot=0;
        }
        if (cnt<(n+1)/2)
        puts("Rejected");
        else if (mx>k)
        puts("Too Slow");
        else if (bot)
        puts("Bot");
        else
        puts("Accepted");
    }
}

VIDEO EDITORIAL:

1 Like

Given testcases are passing but gives WA, it would be really helpful if someone points out for which testcase my code is failing

#include <bits/stdc++.h>
#define in(n, arr)              \
    for (int i = 0; i < n; i++) \
    cin >> arr[i]
#define out(n, arr)             \
    for (int i = 0; i < n; i++) \
    cout << arr[i]
#define lli long long int
#define pb push_back
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    int t;
    cin >> t;

    while(t--)
    {
        int n, k;
        cin >> n>>k;

        vector<int> arr(n);
        in(n, arr);
        bool slow = 0;
        int solvedCount = 0;
        bool check = 0;
        for (int i = 0; i < n; i++)
        {
            if(arr[i] != -1)
                solvedCount++;
            
            if(arr[i] > k)
                slow = 1;

            if(arr[i] <= 1)
                check = 1;
        }

        if(solvedCount < ceil((float)n/2))
            cout << "Rejected\n";
        else if(slow)
            cout << "Too Slow\n";
        else if(solvedCount == n && check)
            cout << "Bot\n";
        else
            cout << "Accepted\n";
    }

    return 0;
}

@shyren_more
It is giving WA because the condition for checking Bot is wrong . Problem Statement says for Bot
“candidate has solved all of the N problems in at most one second each”. So if array contain “0 1 1 2” it shouldn’t return Bot ,but in your code it is.

1 Like