You are not logged in. Please login at www.codechef.com to post your questions!

×

ZCO 2014 Smartphone

Why is my code not getting accepted even when i have tested all selfmade testcases to be running correctly

My code is at given link- link

asked 08 Nov '15, 11:57

vedant2080's gravatar image

0★vedant2080
914
accept rate: 0%


When I opened your code I got a TLE. You are complicating it a little too much. There is a logic in this question which is actually very simple. The maximum profit will always be a multiple of one of the customers budget.

link

answered 12 Nov '15, 19:37

asc4155's gravatar image

2★asc4155
1
accept rate: 0%

The problem is in your merge function. You are arbitrarily declaring an array of 100 size. The constraints are lot higher. Also change all your int's to long long to avoid danger. See here all same with the above changes implemented.

link

answered 12 Nov '15, 22:52

virresh's gravatar image

3★virresh
1404
accept rate: 37%

edited 12 Nov '15, 22:56

Yes , you are right , the problem is in the merge function because of size of the array being 100. That is because it is running correctly because when i give about input of size 10 - 20.

Thanks

(15 Nov '15, 18:08) vedant20800★

tomorrow is exam so you shall use one thing it will save your time. Use algorithm.h it has various functions such as sort() it will sort your array and you won't have to worry for sorting part. example int A[5]={7,6,4,8,1}; sort(A+0,A+4);

link

answered 14 Nov '15, 20:07

alphastar's gravatar image

2★alphastar
295
accept rate: 0%

@asc4155 is right. You are overcomplicating it. Here's my code that fetched me 100 points https://ideone.com/wm4sDz

link

answered 14 Nov '15, 21:17

yash97's gravatar image

2★yash97
1
accept rate: 0%

What's wrong with my code (excluding the slow sorting algorithm)? https://ideone.com/pKbqZh

link

answered 15 Nov '15, 16:15

owneriekno1's gravatar image

2★owneriekno1
11
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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:

×427
×399
×247
×24

question asked: 08 Nov '15, 11:57

question was seen: 2,341 times

last updated: 15 Nov '15, 18:08