WA in spoj DOTAA(10286)

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
himanshuk
New poster
Posts: 1
Joined: Sun Mar 23, 2014 4:03 pm

WA in spoj DOTAA(10286)

Post by himanshuk » Sun Mar 23, 2014 4:19 pm

I know this is a very easy question,but I just dont know why i'm getting wrong answers.Here is the link to problem :http://www.spoj.com/problems/DOTAA/

I am using stl priority queue.

Here is my code:


#include<cstdio>
#include<iostream>
#include<queue>
using namespace std;
priority_queue <int> st;
int main()
{
int T,n,m,d,h,flag,i,tp;
scanf("%d",&T);
while(T>0)
{
scanf("%d %d %d",&n,&m,&d);
for(i=0;i<n;i++)
{
scanf("%d",&h);
st.push(h);
}
for(i=1;i<=m;i++)
{
flag = 0;
if(d >= st.top())
{
flag = 1;
break;
}
else
{
tp = st.top();
tp = tp - d;
st.pop();
st.push(tp);

}

}
if(flag == 1)
printf("NO\n");
else
printf("YES\n");
T--;
}
return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: WA in spoj DOTAA(10286)

Post by brianfry713 » Tue Mar 25, 2014 12:48 am

Try running your code on the sample input.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “C++”