11559 - Event Planning
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11559 Event planning
Try the I/O in this thread.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 10
- Joined: Tue Dec 03, 2013 8:48 pm
Re: 11559 Event planning
i can't find the bug of my code..Help me please !!!!
Code: Select all
#include<bits/stdc++.h>
using namespace std;
int main()
{
long n,b,h,w,minn,p,q,r,i,h_cost;
bool flag,tflag;
while(cin>>n>>b>>h>>w)
{
flag=false;
minn=0;
for(i=1;i<=h;i++)
{
tflag=true;
cin>>h_cost;
//cout<<"1st input"<<endl;
for(int j=1;j<=w;j++)
{
cin>>p;
if(p<w)
{
tflag=false;
}
}
//cout<<tflag<<endl;
//cout<<"2st input"<<endl;
if(tflag)
{
if(h_cost*n<=b)
{
//cout<<"Done"<<endl;
if(minn==0)
{
minn=h_cost*n;
flag=true;
}
else
{
if(h_cost*n<minn)
minn=h_cost*n;
}
}
}
//cout<<minn<<endl;
}
//cout<<minn<<endl;
if(!flag)
cout<<"stay home"<<endl;
else
cout<<minn<<endl;
}
return 0;
}
-
- New poster
- Posts: 10
- Joined: Tue Dec 03, 2013 8:48 pm
11559- Event Planning
i don't know why I am getting wa in this code.
Code: Select all
#include<bits/stdc++.h>
using namespace std;
int main()
{
long n,b,h,w,minn,p,q,r,i,h_cost;
bool flag,tflag;
while(cin>>n>>b>>h>>w)
{
flag=false;
minn=0;
for(i=1;i<=h;i++)
{
tflag=true;
cin>>h_cost;
for(int j=1;j<=w;j++)
{
cin>>p;
if(p<n)
tflag=false;
}
if(tflag)
{
if(h_cost*n<=b)
{
if(minn==0)
{
minn=h_cost*n;
flag=true;
}
else
{
if(h_cost*n<minn)
minn=h_cost*n;
}
}
}
}
if(!flag)
cout<<"stay home"<<endl;
else
cout<<minn<<endl;
}
return 0;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11559- Event Planning
Don't double post
Check input and AC output for thousands of problems on uDebug!
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11559 Event planning
Try the I/O in this thread.
Check input and AC output for thousands of problems on uDebug!
Re: 11559 Event planning
Code: Select all
AC Dlete
Last edited by Blief.S on Tue Jun 24, 2014 8:42 am, edited 2 times in total.
Re: 11559 Event planning
Your code doesn't pass the sample cases from the problem statement—if it appears otherwise in your system, it may be a coincidence.Blief.S wrote:Test cases passed why WA?
Try configuring your compiler to show you all possible warnings, as that can help you catch subtle bugs. For example, I received the following message from your code, which seems important:
Code: Select all
p.cpp:4:22: warning: ‘expense’ may be used uninitialized in this function [-Wmaybe-uninitialized]
int n,b,h,w,rent,expense,m,bed,x,i,j;
^
Re: 11559 Event planning
Thanks it was a sleepy mistake. Do not submit a code when you feel asleep ![:lol:](./images/smilies/icon_lol.gif)
![:lol:](./images/smilies/icon_lol.gif)
-
- New poster
- Posts: 32
- Joined: Tue Jul 22, 2014 1:17 am
11559 - Event Planning
GOT AC!!
Last edited by ehsanulbigboss on Sat Oct 04, 2014 8:57 pm, edited 1 time in total.
Re: 11559 - Event Planning
Your code fails random input here. http://www.udebug.com/UVa/11559
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11559 - Event Planning
Next time post in the existing thread.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 2
- Joined: Wed Feb 11, 2015 4:45 pm
Re: 11559 - Event Planning
can someone give me some critical inputs for this problem? I have tried some random udebug inputs. They all gave right answer. But when submitting i constantly getting WA.Thanks in advance ![:wink:](./images/smilies/icon_wink.gif)
![:wink:](./images/smilies/icon_wink.gif)
Re: 11559 - Event Planning
why wrong ans??
Code: Select all
/* ************************* Template Start ******************************** */
/* MB Talha * */
/* Daffodil International University */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <ctime>
using namespace std;
#define sf scanf
#define pf printf
#define for0(i, n) for(i = 0; i < n; i++)
#define for1(i, n) for( i=1; i<=n; i++)
#define rof(i, n) for(i = n - 1; i >= 0; i--)
#define CLR(n, v) memset(n, v, sizeof( n ))
#define pb push_back
#define sz(n) n.size()
#define sn321(a) scanf("%d", &a)
#define sn322(a,b) scanf("%d %d", &a, &b)
#define sn323(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define sn324(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
#define sn641(a) scanf("%lld", &a)
#define sn642(a,b) scanf("%lld %lld", &a, &b)
#define sn643(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define snD1(a) scanf("%lf",&a)
#define snD2(a, b) scanf("%lf %lf", &a, &b)
#define snD3(a, b, c) scanf("%lf %lf", &a, &b, &c)
#define pn321(a) printf("%d\n", a)
#define pn322(a, b) printf("%d %d\n", a, b)
#define pn323(a, b, c) printf("%d %d %d\n", a, b, c)
#define ln printf("\n")
const double PI = 2 * acos ( 0.0 );
typedef long long lld;
typedef unsigned long long llu;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<vi> v;
template <class T> T jog(T a, T b) { return a + b; }
template <class T> T bog(T a, T b) { return a - b; }
template <class T> T gon(T a, T b) { return a * b; }
template <class T> T sq(T x) {return x * x;}
template <class T> T gcd( T a, T b ) { return b == 0 ? a : gcd(b, a % b); }
template <class T> T lcm ( T a, T b ) { return ( a / gcd ( a, b ) ) * b; }
template <class T> T cordinatlenth(T a, T b, T c, T d) { return sqrt( sq(a - c) + sq(b - d) ); }
lld bigmod ( lld a, lld p, lld mod )
{
lld res = 1, x = a;
while ( p ) {
if ( p & 1 ) res = ( res * x ) % mod;
x = ( x * x ) % mod;
p >>= 1;
}
return res;
}
#define M 1000005
/*
int diraction1[] = {-1, 0, 0, 1, 1, -1, -1, 1};
int diraction2[] = {0, -1, 1, 0, 1, -1, 1, -1};
int horsed1[] = {-2, -2, -1, 1, 2, 2, 1, -1};
int horsed2[] = {1, -1, -2, -2, -1, 1, 2, 2};
/* *************************Template end******************************** */
int main(){
int a,b,c,k,d,n,i,j,p,test,h,w,cost[101],ww[101],cs2;
CLR(cost,0);
sn324(n,b,h,w);
k=0;
for0(i,h){
sn321(p);
d=0;
for0(j,w){
cs2=0;
sn321(ww[j]);
if(ww[j]>=n){
cs2=n*p;
if(cs2<=p){
cost[i]=cs2;
break;
}
else {d++;}
}
else
d++;
}
if(d==w) k++;
}
if(k==h) pf("stay home\n");
else
{
sort(cost,cost+h);
pf("%d\n",cost[1]);
}
}
Re: 11559 - Event Planning
Random input by brianfry713 on uDebug, Passed all test Cases. Here link: http://ideone.com/dTRshf But Getting TLE. Please Help ![:(](./images/smilies/icon_frown.gif)
![:(](./images/smilies/icon_frown.gif)
Re: 11559 - Event Planning
Getting RTE can anyone help?
Code: Select all
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int minimumCost = Integer.MAX_VALUE;
int n = sc.nextInt();
int budget = sc.nextInt();
int hotelCount = sc.nextInt();
int weekendCount = sc.nextInt();
for (int i = 0; i < hotelCount; i++) {
int price = sc.nextInt();
for (int j = 0; j < weekendCount; j++) {
int bedCount = sc.nextInt();
if (bedCount >= n) {
int totalCost = price * n;
if (totalCost <= budget) {
if (totalCost < minimumCost) {
minimumCost = totalCost;
}
}
}
}
}
if (minimumCost == Integer.MAX_VALUE) {
System.out.println("stay home");
} else {
System.out.println(minimumCost + "");
}
}
}
}