×

# It gives me wrong answer although i did it correctly

I am trying to solve this easy problem http://www.codechef.com/problems/CHEFRP . Whenever i run on IDE it gives me correct output however when i try submitting the answer it shows wrong answer could someone please tell me whats wrong? here is my code

# include <iostream>

using namespace std;

int main(void) {

int t,i,n,flag=1,count;
int *q=NULL;
cin>>t;

while(t--)
{
cin>>n;
q = new int[n];
for(i=0;i<n;i++)
{
cin>>q[i];
}
for(i=0;i<n;i++)
{
if(q[i]>=2)
{
count=count+2;
}
else
{
flag=0;
}
}

cout<<count<<endl;
count=0;

if(flag==0)
{
cout<<"-1";
}
}

return 0;


}

14
accept rate: 0%

 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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:

×856

question asked: 24 May '15, 11:52

question was seen: 1,186 times

last updated: 24 May '15, 13:22