CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • May Cook-Off 2013
    • May Challenge 2013
    • April Cook-Off 2013
    • April Challenge 2013
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • Campus Chapters
    • Host your Contest
    • Go for Gold
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
    • Top Contributors on Discuss
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » September Challenge 2012 » ChefTown Parade

ChefTown Parade

Problem code: CHEFTOWN

  • All Submissions

All submissions for this problem are available.

ChefTown is the biggest city and the capital of ChefLand. There are N beautiful buildings: restaurants, museums, living houses with large kitchens and so on. Every building has its height. For every i (1<=i<=N) there is exactly one building with height i. The buildings are located in a single line from left to right. The height of ith building is H(i). The Mayor of ChefTown wants to organize a parade, where all great chefs will take part. A parade depends of its location. The location of a parade is a segment of consecutive buildings beginning near the building number L and ending near the building number R (1<=L<=R<=N). Any parade won't be interesting if it is not hold on an interesting segment of buildings. The segment of buildings is interesting if following are hold:

  • Imagine, that we have a segment [L,R].
  • Let K=R-L+1 be the length of this segment, and B be a list of heights of the buildings that belong to this segment.
  • Let's sort B in non-decreasing order.
  • Segment [L,R] is interesting if B[i]-B[i-1]=1 for every i (2<=i<=K).

Now the Mayor of ChefTown is interested how many ways to organize an interesting parade of length W for ChefTown citizens. Help him and find out the number of different parades of length W, which can be hold in the city. Two parades ([L1,R1] and [L2,R2]) are considered to be different, if L1≠L2 or R1≠R2.

Input

Each input file consists of two lines, the first one contains two integers N and W (1<=N<=400000, 1<=W<=N). The second line contains N numbers H(i) (1<=i<=N) - the heights of the buildings.

Output

For each test case output a single integer - the number of interesting segments of buildings of length W.

Example

Input 1:
2 1
2 1
Input 2:
4 2
1 2 3 4

Output for Input 1:
2
Output for Input 2:
3


Author: Rubanenko
Tester: laycurse
Editorial http://discuss.codechef.com/problems/CHEFTOWN
Date Added: 3-08-2012
Time Limit: 1 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

@admin i am not getting this

mishra_pk @ 1 Sep 2012 05:14 PM
@admin i am not getting this question. help what is output for 10 3 3 8 7 6 9 5 1 4 2 3 Is it 2 or 6?

@mishra-pk answer is 2

tornike4 @ 1 Sep 2012 05:51 PM
@mishra-pk answer is 2

@admin : The problem

mng88 @ 1 Sep 2012 05:53 PM
@admin : The problem statement reads : "For every i (1<=i<=N) there is exactly one building with height i ". Please clear this, did you mean "there is exactly one building with height H(i) " ? I mean, are all the heights different ?

@mishra_pk test incorrect:

pva701 @ 1 Sep 2012 05:58 PM
@mishra_pk test incorrect: For every i (1<=i<=N) there is exactly one building with height i.

@pva701 then what should be

mishra_pk @ 1 Sep 2012 07:05 PM
@pva701 then what should be output for 10 3 3 8 7 6 9 5 1 4 2 10 Is it 1?

@admin cant understand input

giorgi @ 1 Sep 2012 07:30 PM
@admin cant understand input output format. please explain

finally AC...

mishra_pk @ 1 Sep 2012 07:46 PM
finally AC...

from where i should give

cwitharup @ 1 Sep 2012 08:02 PM
from where i should give input..through any input file??

What is wrong with input and

pat3ik @ 1 Sep 2012 08:20 PM
What is wrong with input and output? My program doesn't get anything from standard input.

gettin tle ...nyone can

lcoder @ 1 Sep 2012 08:31 PM
gettin tle ...nyone can help!!

Moreover, for N = 400000, W =

flareneos @ 1 Sep 2012 08:51 PM
Moreover, for N = 400000, W = 2 (worst case), it works on my not-so-special PC 0.7sec. Admin, can you please check this? Thanks in advance

I have also N log N solution

pat3ik @ 1 Sep 2012 08:55 PM
I have also N log N solution but I get Time Limit. I think the problem is in input, because my program doesn't get anything from standard input.

Yeah, awkward.. That's why

flareneos @ 1 Sep 2012 09:02 PM
Yeah, awkward.. That's why probably the program doesn't even finish its job. Admin, please check this for us :)

@flareneos spoj servers are

roman_adm @ 1 Sep 2012 09:13 PM
@flareneos spoj servers are quite slow, so you need to make your programm faster.

IMP : Is the time limit not

tanujrastogi @ 1 Sep 2012 09:24 PM
IMP : Is the time limit not applicble in this contest??Solutions with time exceeded are being accepted and awarded scores. Don't we need to write efficient codes this time??

roman_adm @ can you explain

giorgi @ 1 Sep 2012 09:34 PM
roman_adm @ can you explain me inpot output format?

@tanujrastogi: if you are

AnoopNarang @ 1 Sep 2012 09:35 PM
@tanujrastogi: if you are referring to the timetaken by accepted solutions, it is not the time taken by 1 test File, it is the sum of time taken by all test files passed to the program. Just the condition is every test file should take time less than the given time limit.

But I think it's a bit

flareneos @ 1 Sep 2012 09:44 PM
But I think it's a bit unfair, because my implementation is pretty good.. Maybe there is one thing I can improve, but it's all. Can't believe server is so slow :(

i am getting TLE in nlogn

rock21293 @ 1 Sep 2012 10:47 PM
i am getting TLE in nlogn complexity please anybody help..

Definitely should be 1.5s-2s

flareneos @ 1 Sep 2012 10:49 PM
Definitely should be 1.5s-2s time limit..

The time limit is too tight

Ric4 @ 1 Sep 2012 10:58 PM
The time limit is too tight O(n) soln is not being AC where its running in 0.3 s on my comp.

i don't get this

as9405 @ 1 Sep 2012 10:59 PM
i don't get this question.plzzz help me .

plzzz give two more exmples.

as9405 @ 1 Sep 2012 11:05 PM
plzzz give two more exmples.

@flareneos server is not

nirajn007 @ 1 Sep 2012 11:06 PM
@flareneos server is not slow...........read frequently asked Q if u think ur perfect with logic nn all..........dats all i could say.................

Finally AC .. just replaced

Ric4 @ 1 Sep 2012 11:06 PM
Finally AC .. just replaced new int[400001] with new int[n] after scanf(n).. thats odd...

am not getting constraints

devilz_007 @ 1 Sep 2012 11:58 PM
am not getting constraints for H(i)... can anyone help me plz....

@devilz_007 "For every i

roman_adm @ 2 Sep 2012 12:00 AM
@devilz_007 "For every i (1<=i<=N) there is exactly one building with height i" Be attentive, because it is written in the statement.

@roman_adm thanks for

devilz_007 @ 2 Sep 2012 12:18 AM
@roman_adm thanks for clearing it out...and am sorry i got confused with that H(i)....

@devilz_007 You're wellcome:)

roman_adm @ 2 Sep 2012 12:35 AM
@devilz_007 You're wellcome:)

lol... my C++ code runs but

pis113 @ 2 Sep 2012 01:29 AM
lol... my C++ code runs but the same (exactly same) gets TLE in Java with O(n).... Now wondering why is the discrimination ???

1:Each input file consists of

giorgi @ 2 Sep 2012 01:34 AM
1:Each input file consists of two lines, 2:For each test case output a single integer is there 1 test or more?

@giorgi Yeah, as You can see

roman_adm @ 2 Sep 2012 01:56 AM
@giorgi Yeah, as You can see from the examples and the statesmant there is one test case per input file.

@pis113 TL may be caused by

roman_adm @ 2 Sep 2012 02:00 AM
@pis113 TL may be caused by your I/O methods. As you can see from the submissions lists - this problem is accepteble in Java.

@admin: Codes outputting 1

karthikabinav @ 2 Sep 2012 01:27 PM
@admin: Codes outputting 1 and 0 for 4 4 1 3 2 4 are both getting accepted . Could you check the test cases again.

@admin: my code outputs 0 for

sai7393 @ 2 Sep 2012 01:32 PM
@admin: my code outputs 0 for 5 3 1 3 4 2 5 as input which i guess is wrong.It still got accepted. I guess the test cases havent considered these.

@karthikabinav and

flareneos @ 2 Sep 2012 01:39 PM
@karthikabinav and @sai7393 Wrong test cases. Array is permutation [1, n]

@flareneos: 1 3 2 4 is a

karthikabinav @ 2 Sep 2012 02:03 PM
@flareneos: 1 3 2 4 is a permutation of [1..4] . I put the test case in the question format. I meant n = 4 , w = 4 and heights = { 1, 3, 2 ,4}

Can anybody explain the input

cupidvogel @ 2 Sep 2012 03:15 PM
Can anybody explain the input format? What is it with input files here? We normally do it on the command prompt itself, so please provide the syntax for doing that.

Which ancient machine you

_arjun @ 2 Sep 2012 04:09 PM
Which ancient machine you guys are using ?

do we need to input several

priyanshuid @ 2 Sep 2012 06:45 PM
do we need to input several test cases or just one test case is to be considered

worst case will be 40,000

nirajs @ 2 Sep 2012 09:05 PM
worst case will be 40,000 20,000

Made O(N) solution, still

flareneos @ 2 Sep 2012 09:27 PM
Made O(N) solution, still TLE. I guess you guys are using Commodore 64. Completely unfair time limit. Giving up

@admin i'm getting

code_chef_nits @ 2 Sep 2012 10:29 PM
@admin i'm getting tle.....does it have any relation with 4.1 mb that my code occupies...? and in case of memory exceeding....do i get tle or anything else.....?

@admin do we need to input

priyanshuid @ 2 Sep 2012 11:02 PM
@admin do we need to input several test cases or just one test case is to be considered?

@admin do we need to input

priyanshuid @ 2 Sep 2012 11:03 PM
@admin do we need to input several test cases or just one test case is to be considered

As I go through the above

parikshit979 @ 2 Sep 2012 11:04 PM
As I go through the above comments,I feel that many solutions with wrong output are accepted and Many people (including ME) with correct output and O(N) or O(NlogN) complexity are getting TLE. Admin Plzzz reply...

how does 2 1 2 1 give ans as

ajit_a @ 3 Sep 2012 12:04 AM
how does 2 1 2 1 give ans as 2 ?? LR combinations are (1,1),(1,2)(2,2) from which only (1,2) satisfies the condition. Some1 please give me a hint..

How is (1,2) of length 1 ?

flareneos @ 3 Sep 2012 12:36 AM
How is (1,2) of length 1 ? Lol. And (1,1) and (2,2) satisfy the condition. @parikshit979 completely right. Fail constraints.

@admin what should be the

amey_mhatre91 @ 3 Sep 2012 01:09 AM
@admin what should be the output when W=N??

I am getting RTE and this is

ajit_a @ 3 Sep 2012 01:34 AM
I am getting RTE and this is my Idone o/p language: C99 strict (gcc-4.3.4) result: Success time: 0.01s memory: 3240 kB returned value: 0 input: 4 2 4 3 2 1 output: 3 What can be the issue ?

Is there a O(n) solution ??

olimpo @ 3 Sep 2012 02:11 AM
Is there a O(n) solution ??

@admin, the 4th bullet above

bodmas @ 3 Sep 2012 02:34 AM
@admin, the 4th bullet above says Segment [L,R] is interesting if B[i]-B[i-1]=1 for every i (2<=i<=K). How come the answer to first testcase is 2 when W is 1 and K=W=1 does not satisfy the condition 2<=i<=K, please clarify.

@Kurama Don't share your

roman_adm @ 3 Sep 2012 10:43 AM
@Kurama Don't share your ideas about solving andy problem during the contest, please. It is against our rules.

@bodmas It's ok, since there

roman_adm @ 3 Sep 2012 11:03 AM
@bodmas It's ok, since there is no any i that B[i]<>B[i-1]+1. You should understand in such the way. Regards, Roman Rubanenko

Is there a O(n) solution ??

lashabuxo @ 3 Sep 2012 04:29 PM
Is there a O(n) solution ??

@roman_adm, I'm sorry for

kuruma @ 3 Sep 2012 04:51 PM
@roman_adm, I'm sorry for that... Will O(N) suffice?

@admin-when to stop reading

ridder @ 3 Sep 2012 08:27 PM
@admin-when to stop reading input, EOF or 0 0 ??

o(n) giving tle!!!!!!!

xyz123456 @ 3 Sep 2012 08:28 PM
o(n) giving tle!!!!!!!

for input 40000 20000 my code

durgesh333 @ 3 Sep 2012 08:33 PM
for input 40000 20000 my code is running for 0.48 sec , still getting TLE :-(

do we need to input several

annem55 @ 3 Sep 2012 08:34 PM
do we need to input several test cases or just one test case is to be considered ????and is it through command prompt or files??

someone answer please...

annem55 @ 3 Sep 2012 09:19 PM
someone answer please...

@roman_adm - check ur input

avenger_coder @ 3 Sep 2012 09:44 PM
@roman_adm - check ur input file it is wrong.. take all sorted element.. 4 4 4 3 1 2 code with both 1 and 0 are AC ... please have a look and rejudge..

what is the input format

sunil12345 @ 3 Sep 2012 10:44 PM
what is the input format could somebody explain like what(names) are the files each having 2 lines each .

I hv done it in single

nitajay28 @ 3 Sep 2012 11:18 PM
I hv done it in single traversal bt agn its shwing TLE..........???

I hv done it in single

nitajay28 @ 3 Sep 2012 11:18 PM
I hv done it in single traversal bt agn its shwing TLE..........???

@nitajay28 You may also try

roman_adm @ 4 Sep 2012 09:18 AM
@nitajay28 You may also try change your I/O methods. Regards, Roman Rubanenko

@avenger_coder Yeah,

roman_adm @ 4 Sep 2012 09:20 AM
@avenger_coder Yeah, probably, we will add new test cases these days.

@admin : seriously check your

argonaut @ 4 Sep 2012 11:05 AM
@admin : seriously check your testcases, considered every possible case still WA... :(

@roman_adm I am also doing it

vineetsetia @ 4 Sep 2012 11:13 AM
@roman_adm I am also doing it in single traversal, and in addition I am also calculating it while taking input..still getting TLE..

@roman_adm Problem above

ecr123 @ 4 Sep 2012 04:29 PM
@roman_adm Problem above states: "Two parades ([L1,R1] and [L2,R2]) are considered to be different, if L1≠L2 or R1≠R2" ---- does this mean to "interesting" segments can overlap?

hi guys, please help ..what's

ecr123 @ 4 Sep 2012 04:31 PM
hi guys, please help ..what's the output for this test case? 10 3 2 7 9 8 10 15 3 5 4 6 ...

@annem55 input must be from

ecr123 @ 4 Sep 2012 04:33 PM
@annem55 input must be from the standard input or console or command line ... you can have as many test cases possible

@ecr123 is output for ur test

gokugohan @ 4 Sep 2012 04:52 PM
@ecr123 is output for ur test case 4.......??

how many test cases are there

gokugohan @ 4 Sep 2012 04:55 PM
how many test cases are there in input can anyone help.... is there only one test case.

@roman_adm Is the answer for

ecr123 @ 4 Sep 2012 05:13 PM
@roman_adm Is the answer for this test case 4? 10 3 2 7 9 8 10 15 3 5 4 6

@gokugohan i think 1 test

ecr123 @ 4 Sep 2012 05:14 PM
@gokugohan i think 1 test case per input file. thanks for trying to help.

@admin test data might be

Sumudu @ 4 Sep 2012 05:23 PM
@admin test data might be weak, my program was definitely wrong but was AC yesterday. Please take a look (sub. 1297971; counts too many segments as interesting sometimes). email if you want more details since putting them here would give away something.

@admin please EXPLAIN input

hrdktg @ 4 Sep 2012 08:34 PM
@admin please EXPLAIN input #1.

Can the input be 10 2 3 4 3 4

ravi1236 @ 4 Sep 2012 10:29 PM
Can the input be 10 2 3 4 3 4 3 4 3 4 3 4 i.e is the above input valid?.. I tried with almost all the test cases, also tried the input mentioned above.. still it says wrong answer.. What might be the problem :(

Is 10 10 10 9 0 1 2 3 4 5 6 7

ravi1236 @ 4 Sep 2012 10:30 PM
Is 10 10 10 9 0 1 2 3 4 5 6 7 8 a valid input?

Is standard input/output fine

michael10024 @ 5 Sep 2012 12:21 AM
Is standard input/output fine for the time limit?

am using nlogn..... still

devilz_007 @ 5 Sep 2012 12:24 AM
am using nlogn..... still getting tle.....can anyone who have solved this problem tell me his/her algo's complexity......

@devilz_007: You are just

nishchay2192 @ 5 Sep 2012 02:54 AM
@devilz_007: You are just misinterpreting the problem as we all did. It's simpler than you think it to be.

@admin, according to the time

bodmas @ 5 Sep 2012 03:37 AM
@admin, according to the time limits, does it mean that my program must provide answers to all the input files within 1 sec?

optimised input..!, output in

kp25 @ 5 Sep 2012 08:26 AM
optimised input..!, output in a single traversal thru array, yet time limit :(

@roman_adm Is the answer for

ecr123 @ 5 Sep 2012 09:34 AM
@roman_adm Is the answer for this test case 4? 10 3 2 7 9 8 10 15 3 5 4 6

for 3 1 3 1 2 is ans is 3 or

khadarbasha @ 5 Sep 2012 10:49 AM
for 3 1 3 1 2 is ans is 3 or 2?

@Admin I have a

ajit_a @ 5 Sep 2012 12:36 PM
@Admin I have a doubt. suppose if the program logic is wrong an exceeding the TL then will I get WA or TLE ?? Otherwise we would wast time on improving the efficiency rather than working on the logic... :P

@ admin this is ridiculous

selfcompiler @ 5 Sep 2012 02:29 PM
@ admin this is ridiculous why the wrong submission getting accepted

I am getting all d test cases

getanna009 @ 5 Sep 2012 02:30 PM
I am getting all d test cases like dose mentioned in comments... still not accepted :(

can any one tell me the

akashheart02 @ 5 Sep 2012 04:52 PM
can any one tell me the special case. my code is running fine but still getting WA.

do recursive programs run

imaunuay0 @ 5 Sep 2012 05:44 PM
do recursive programs run even slower on SPOJ?

getting TLE for O(n) ... is

shankey_adi @ 5 Sep 2012 05:54 PM
getting TLE for O(n) ... is it because of Java?

Any hint to get input faster

ajit_a @ 5 Sep 2012 06:58 PM
Any hint to get input faster ??

Very ambiguous problem

siddharthchan @ 5 Sep 2012 07:08 PM
Very ambiguous problem statement .

@nishchay2192 : am

devilz_007 @ 5 Sep 2012 08:21 PM
@nishchay2192 : am misinterpreting? interesting....can u give a very lil hint ....nothing else is clicking me except that nlogn algo... :P

nlogn can pass.... try to

s_bond @ 5 Sep 2012 08:26 PM
nlogn can pass.... try to minimize the constant and avoid hashing...

pl explain 1 example

grishmashah @ 5 Sep 2012 10:09 PM
pl explain 1 example

@admin : please clarify that

akhil_nsit_win @ 6 Sep 2012 12:21 AM
@admin : please clarify that : 4 2 4 4 15 1 a valid input? i mean can there be repitation or can any height be greater than N?

Was there rejudge? My

EgorK @ 6 Sep 2012 11:01 AM
Was there rejudge? My accepted submission became RTE

Can you please recheck test

EgorK @ 6 Sep 2012 11:14 AM
Can you please recheck test data? My solution throws exception on attempt to read input data acording to specifications.

Yes, I made my input reading

EgorK @ 6 Sep 2012 11:17 AM
Yes, I made my input reading to fill tail of array with 0s when it can't read them (default C++ behavior) and got Accepted

Still getting LTE ...when I'm

sartorius @ 6 Sep 2012 02:49 PM
Still getting LTE ...when I'm dealing with wost cases (400000/200000 and so on) on my machine in 0.25 sec ... strange ...

@EgorK Yes, the submissions

hiroto_adm @ 6 Sep 2012 04:48 PM
@EgorK Yes, the submissions are rejudged, since it turns out that test cases are a bit weak. And I found a bug in the one of new test cases, and I have fixed it. All submissions will be rejudged one more time. Sorry for the inconvenience, and thanks for the report.

can nyone explain how to take

adityaharish @ 6 Sep 2012 05:21 PM
can nyone explain how to take the input . ? I don't know any file name so how can I take input from a file ..!

@admin : the test cases are

mohamed_gaber @ 7 Sep 2012 02:06 AM
@admin : the test cases are still very weak there is an accepted code that doesn't handle cases like n=4 , m = 2 heights = (4, 3 ,2 , 1) and n = 5, m = 4 heights = (2,4,1,3,5). this accepted code doesn't take into consideration that the condition is on array B which is a sorted array as mentioned in the problem • Let’s sort B in non-decreasing order. • Segment [L,R] is interesting if B[i]-B[i-1]=1 for every i (2<=i<=K). it is just check the condition in the array a

@admin: Time limit is very

arcturus @ 7 Sep 2012 06:55 AM
@admin: Time limit is very funny. After rejudging, my previously AC submission became TLE. I tried submitting it once again (the very same code) and it was AC once again..

I'm in the same situation as

hotoku @ 7 Sep 2012 08:10 AM
I'm in the same situation as @sartorius. My O(n log w) algorithm works in less than 0.4sec on my own machine without any optimization option. But I got TLE.....

@admin: Have the solutions

t1g3 @ 7 Sep 2012 01:16 PM
@admin: Have the solutions been rejudged?

@mohamed_gaber what is the

k0stia @ 7 Sep 2012 01:30 PM
@mohamed_gaber what is the correct answer for your test cases ?

Getting no response after

poojits @ 7 Sep 2012 05:42 PM
Getting no response after submission. It's saying Successful Submission and stuck on "Running". Any problem after the site went down and came back up?

same code tle in java and ac

karan173 @ 7 Sep 2012 09:18 PM
same code tle in java and ac in c++!

any body ..plz tell me the

avi007008 @ 7 Sep 2012 10:37 PM
any body ..plz tell me the format of input Is it console input or File input

it's ALWAYS console input...

kuruma @ 8 Sep 2012 02:40 AM
it's ALWAYS console input...

anyone feels like giving a

kuruma @ 8 Sep 2012 02:41 AM
anyone feels like giving a small hint? Got over 30 wrong/TLE submissions, used all I can think of... I don't honestly understand...

submission id 1332645- got AC

jpsarathy23 @ 8 Sep 2012 11:26 AM
submission id 1332645- got AC when submitted but status changed into TLE in the submissions page..

"For every i (1<=i<=N) there

mystery1988 @ 8 Sep 2012 02:05 PM
"For every i (1<=i<=N) there is exactly one building with height i." Does it mean that all elements in the array are distinct?

please try and give some more

p1p5_5 @ 8 Sep 2012 06:38 PM
please try and give some more test cases...

Tried in every language

codersrikant @ 8 Sep 2012 07:00 PM
Tried in every language possible... my O(n) solution giving TLE... can someone help?

I am going to write this

mbaros @ 8 Sep 2012 07:45 PM
I am going to write this program, but I interested will be the nlogn solution AC ??

@admin i solved this problem

nirajn007 @ 9 Sep 2012 01:22 AM
@admin i solved this problem earlier nn it was accepted,now its not in the list of solved problems by me........kindly look into it.........thanx

@admin ..how come an O(n)

ankesh_iitkgp @ 9 Sep 2012 04:13 AM
@admin ..how come an O(n) algorithm give TLE..please look into this

@admin, based on my first

bodmas @ 9 Sep 2012 04:44 AM
@admin, based on my first post, please clarify the case for W=1. should output always be N for W=1?

@roman admin : very nice

kavishrox @ 9 Sep 2012 06:10 AM
@roman admin : very nice question indeed I must say ... hope I can do it...

I know the codechef judge is

neil_812 @ 9 Sep 2012 06:17 AM
I know the codechef judge is slow, but this is getting ridiculous. I've optimized my code until the worst case runs in 0.2s on my 2.2GHz computer, yet it's still getting TLE... so frustrating!

I have a question:The program

angelos_pele1 @ 9 Sep 2012 10:19 PM
I have a question:The program will read N and W by file or by keyboard?

Will there be a T indicating

naqvitalha @ 10 Sep 2012 12:45 AM
Will there be a T indicating number of test cases on top?

Now this is really pissing

bodmas @ 10 Sep 2012 04:45 AM
Now this is really pissing me off. I believe my algorithm and its implementation are correct, given the above constraints, I've run several brute force to confirm its correctness, yet I'm getting WA. What the heck!

Hi, I am getting the

jayantjpr @ 10 Sep 2012 10:17 AM
Hi, I am getting the following peculiar Compilation error ===> /usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/crt1.o: In function `_start': /home/aurel32/tmp/glibc/glibc-2.9/csu/../sysdeps/i386/elf/start.S:115: undefined reference to `main' collect2: ld returned 1 exit status <=== The code is compiling correctly on my machine(RHEL 6 => gcc 4.4.6) using the command 'g++ -pipe -O2 -lm -s -fomit-frame-pointer -Wall prog.cpp'. I have used 'int main()' and 'return 0' (at the end of the main function). If anyone could predict why the problem is occurring, please help! Regards Jayant

question would have been

migdal @ 11 Sep 2012 02:35 AM
question would have been better if heights were arbitary then i would not be able to solve this question :)

@hitesh024 : you are right.

joamon @ 11 Sep 2012 12:42 PM
@hitesh024 : you are right. mine too giving wrong answer on above test case but still got AC ...

@admin test cases are still

hitesh024 @ 11 Sep 2012 02:12 PM
@admin test cases are still wrong for n=16 w=4 1 6 11 16 2 5 15 12 3 8 10 13 4 7 9 14 answer accepted should be 0 but it is accepting 1 also

can some help me why this

ajit_a @ 11 Sep 2012 03:49 PM
can some help me why this code is giving runtime error ? http://ideone.com/LvFZD

I first got my answer

s1aurabhpal_7 @ 11 Sep 2012 04:44 PM
I first got my answer accepted and then after refreshing the webpage it showed TLE. I am very disappointed.please look at these server issues of yours :

I got AC and then, when

deinier @ 12 Sep 2012 06:39 AM
I got AC and then, when system refresh, I got TLE. Well, it is not good.

Great, I send again my

deinier @ 19 Sep 2012 01:07 AM
Great, I send again my solutions and get AC. Take a look, http://www.codechef.com/viewsolution/1357402, I dont understand why I got TLE in the Contest.

SUCCESSFUL SUBMISSIONS


Fetching successful submissions

CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.