10347 - Medians

All about problems in Volume 103. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

atiburrahman09
New poster
Posts: 6
Joined: Mon Mar 26, 2012 10:12 pm

Re: 10347-WHY TLE???

Post by atiburrahman09 »

yeah....but why......


#include<iostream>
#include<stdio.h>
using namespace std;
#include<cmath>
#include<iomanip>
#include<cstdio>


int main(){
int med1,med2,med3;
double area,s,a,b,c,x;


while(cin>>med1>>med2>>med3)
{

if((med1+med2)>med3 && (med1+med3)>med2 && (med2+med3)>med1)
{
s=(med1+med2+med3)*0.5;
x=sqrt(s*(s-med1)*(s-med2)*(s-med3));
area=(4.000*x)/3.000;
}
else
area=-1.000;

if(area>=0)
cout<<fixed<<setprecision( 3 ) << area << endl;
else
cout<<1.000;
}


return 0;
}


this one is also giving WA....but why????
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10347-WHY TLE???

Post by brianfry713 »

Input:
0 3 3

AC Output
-1.000
Check input and AC output for thousands of problems on uDebug!
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10347-WHY TLE???

Post by brianfry713 »

try reading the input as doubles instead of ints.
Check input and AC output for thousands of problems on uDebug!
Post Reply

Return to “Volume 103 (10300-10399)”