11559 - Event Planning

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

Moderator: Board moderators

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

Re: 11559 Event planning

Post by brianfry713 » Mon Mar 17, 2014 11:21 pm

Try the I/O in this thread.
Check input and AC output for thousands of problems on uDebug!

musfiqur.cse
New poster
Posts: 10
Joined: Tue Dec 03, 2013 8:48 pm

Re: 11559 Event planning

Post by musfiqur.cse » Wed Jun 04, 2014 9:55 pm

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

musfiqur.cse
New poster
Posts: 10
Joined: Tue Dec 03, 2013 8:48 pm

11559- Event Planning

Post by musfiqur.cse » Sun Jun 08, 2014 12:56 pm

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

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

Re: 11559- Event Planning

Post by brianfry713 » Mon Jun 09, 2014 11:24 pm

Don't double post
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: 11559 Event planning

Post by brianfry713 » Mon Jun 09, 2014 11:24 pm

Try the I/O in this thread.
Check input and AC output for thousands of problems on uDebug!

Blief.S
New poster
Posts: 16
Joined: Wed Jun 18, 2014 9:03 pm

Re: 11559 Event planning

Post by Blief.S » Mon Jun 23, 2014 2:27 pm

Code: Select all

AC Dlete
Last edited by Blief.S on Tue Jun 24, 2014 8:42 am, edited 2 times in total.

lbv
Experienced poster
Posts: 128
Joined: Tue Nov 29, 2011 8:40 am

Re: 11559 Event planning

Post by lbv » Mon Jun 23, 2014 9:33 pm

Blief.S wrote:Test cases passed why WA?
Your code doesn't pass the sample cases from the problem statement—if it appears otherwise in your system, it may be a coincidence.

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

Blief.S
New poster
Posts: 16
Joined: Wed Jun 18, 2014 9:03 pm

Re: 11559 Event planning

Post by Blief.S » Tue Jun 24, 2014 8:41 am

Thanks it was a sleepy mistake. Do not submit a code when you feel asleep :lol:

ehsanulbigboss
New poster
Posts: 32
Joined: Tue Jul 22, 2014 1:17 am

11559 - Event Planning

Post by ehsanulbigboss » Thu Oct 02, 2014 8:50 pm

GOT AC!!
Last edited by ehsanulbigboss on Sat Oct 04, 2014 8:57 pm, edited 1 time in total.

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 11559 - Event Planning

Post by lighted » Fri Oct 03, 2014 11:42 am

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

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

Re: 11559 - Event Planning

Post by brianfry713 » Sat Oct 04, 2014 12:44 am

Next time post in the existing thread.
Check input and AC output for thousands of problems on uDebug!

tusher.ahamed
New poster
Posts: 2
Joined: Wed Feb 11, 2015 4:45 pm

Re: 11559 - Event Planning

Post by tusher.ahamed » Wed Feb 11, 2015 7:03 pm

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:

fmmst
New poster
Posts: 2
Joined: Tue Jun 09, 2015 8:35 am

Re: 11559 - Event Planning

Post by fmmst » Sat Jul 04, 2015 9:15 pm

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

prokawsar
New poster
Posts: 7
Joined: Tue Aug 04, 2015 5:01 pm

Re: 11559 - Event Planning

Post by prokawsar » Tue Aug 25, 2015 10:14 am

Random input by brianfry713 on uDebug, Passed all test Cases. Here link: http://ideone.com/dTRshf But Getting TLE. Please Help :(

sagarcse
New poster
Posts: 1
Joined: Fri Oct 02, 2015 4:09 pm

Re: 11559 - Event Planning

Post by sagarcse » Fri Oct 02, 2015 4:11 pm

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 + "");
            }
        }
    }
}


Post Reply

Return to “Volume 115 (11500-11599)”