Can you tell me which test case it is failing?

I am writing solution for http://codeforces.com/contest/768/problem/A but it is giving WA on 10th test case. Here is my code:

#include <iostream>
#include <bits/stdc++.h>
#define ll long long int
using namespace std;


int main() {
	// your code goes here

	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
        cin>>a[i];
    cout<<n-2;
    return 0;
}

You have overlooked two important cases, I think.

Firstly if N=1, your program will print N-2, which is equal to -1, while the answer should be 0.

Another case that you haven’t considered is that two or more stewards can have the same value.
For example, if N=3, and the stewards have values: 4,4,4; your program will print 1, while the correct answer is 0.

Hope this was helpful.

2 Likes

thanks for your time…

2 Likes