×

WA in Maximum Number (MAXNUM3) LTIME53

 0 Can someone give a test case where my code fails or rather guide me to the correct approach ? After taking care of the last digit cases, I'm using a greedy approach to find the first number that on removal will lead to (sum of digits) %3=0 and has the next number greater than itself. If such a number doesn't exist, I remove the lowest rightmost number that will lead to that result. asked 28 Oct '17, 23:18 6★trijeet 235●5 accept rate: 25%

 0 havent taken care of the case when last%2 == 0 and l2%2 == 0. answered 28 Oct '17, 23:23 142●5 accept rate: 11% That's when the greedy approach is used. (28 Oct '17, 23:26) trijeet6★ consider the case 3 960. the answer should be 96 (28 Oct '17, 23:27)
 0 I applied the same technique, passed only subtask2. Didn't understand where the approach is wrong. code answered 28 Oct '17, 23:31 11●3 accept rate: 0%
 0 In your code on line 73: x < a[i+1]-'0' this condition is wrong because it doesn't guarantee that the resulting number after deleting a digit will be greater than the one you found earlier. Consider this test case: Input 2 668 663 Your Output -1 66 Correct Output 66 66 answered 28 Oct '17, 23:34 2★a_d_i 174●6 accept rate: 23%
 0 Can anyone tell me due to which testcase it was showing wrong answer? https://www.codechef.com/viewsolution/15992665 answered 29 Oct '17, 00:09 2★spp____ 1.1k●2●11 accept rate: 7% 1 Input: 1 6666666666 Correct Output: 666666666 Your Output: (29 Oct '17, 00:22) a_d_i2★ I'm noob in java so I can't help you with why your code gives no output but I can say that you've read the question wrong. I see you've taken input as integer which is wrong because the input constraint says that input number can be of 10^5 digits long i.e input number can be 10^(10^5) which your long int input can't handle. Try implementing using string. Hope it helps. (29 Oct '17, 00:27) a_d_i2★ thanks @a_d_i (29 Oct '17, 00:28) spp____2★ You're welcome bro. (29 Oct '17, 00:44) a_d_i2★
 0 If you want another approach, Have a look here. If you wannna find bug in your approach, explain it in a bit detail. :) answered 29 Oct '17, 00:24 3.9k●23●87 accept rate: 22%
 0 Can anyone give me a test case where my code fails? It's working well for all the test cases I checked. PLEASE HELP ME!!! I'm storing the digits in an array from one's place. Then I am iterating through all the digits and finding the new number by removing that particular digit. Now, I'm checking whether it is divisible by 6 or not and if it is then I check whether it is largest number possible which I initially set to -1. At last I'm printing the new number with k-1 digits where k is the total number of digits in the initial number. Leading zeros will be printed since I used %0*d and passed k-1 and maxnum to it. LINK:- My Solution answered 29 Oct '17, 00:29 2★ramini 61●5 accept rate: 8% It would time out. The solution time complexity is O(N^2) which won't pass. (29 Oct '17, 00:33) Further, the number can have 10^5 digits, thus, can't be stored in int or even long long. (29 Oct '17, 00:34) But it's giving wrong answer (29 Oct '17, 00:37) ramini2★ n can be 100000 so it can only have a maximum of 6 digits right? (29 Oct '17, 00:38) ramini2★ n can have 100000 digits . So you can't store it in int (29 Oct '17, 00:38) spp____2★ But in constraints it is giving n>=2 (29 Oct '17, 00:39) ramini2★ Ok @ramini , your output for 66666666666666666 is coming -1 which is wrong (29 Oct '17, 00:45) spp____2★ @spp___ There's no single digit input in this question. Read the constraints carefully. 2<= n <= 10^5 (29 Oct '17, 00:46) a_d_i2★ n= no.of digits the number has !!!! (29 Oct '17, 00:50) showing 5 of 9 show all
 0 Try the following: 333966 => 33966 369369 => 69369 123456 => 12456 123126 => 12312 654321 => 65421 162132 => 16212 167137 => 17137 137167 => 17167 answered 29 Oct '17, 04:09 3★djvdm123 73●4 accept rate: 0%
 -1 why u define soo much macro's? answered 28 Oct '17, 23:26 -1 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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:

×1,056
×358
×64
×12

question asked: 28 Oct '17, 23:18

question was seen: 617 times

last updated: 29 Oct '17, 04:09