You are not logged in. Please login at www.codechef.com to post your questions!

×

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;
}

asked 09 Jul, 22:30

montycs's gravatar image

0★montycs
1054
accept rate: 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.

link

answered 10 Jul, 01:11

akashbhalotia's gravatar image

4★akashbhalotia
45412
accept rate: 2%

edited 11 Jul, 20:06

1

thanks for your time..

(10 Jul, 11:42) montycs0★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×607

question asked: 09 Jul, 22:30

question was seen: 133 times

last updated: 11 Jul, 20:06