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

×

SPOJ KQUERY NZEC

http://www.spoj.com/problems/KQUERY/

https://ideone.com/tHwf3h

Getting runtime error repeatedly..Is it because of memory limit exceeded?? Or an invalid memory access(arrayindex out of bound exception) ??

BTW, the approach I used here is - A segment tree where each node stores an sorted interval. For a query i then join different disjoint intervals and then i perform a binary search over the newly formed interval to get number of elements which are greater than k.

asked 24 Dec '14, 19:09

abeyaar's gravatar image

1★abeyaar
33422140
accept rate: 30%

edited 24 Dec '14, 19:12

can anyone help??

(29 Dec '14, 21:31) abeyaar1★

I think Segment Tree will get TLE for this problems. I try to solve by Fenwick Tree and got AC. I think because of CPU which is used to judge that problem.

link

answered 29 Dec '14, 22:05

leduongtuananh's gravatar image

2★leduongtuananh
12528
accept rate: 16%

It can be solved with Segment tree but fast i/o is required (even faster than scanf/printf).

(29 Dec '14, 22:22) neo1tech9_76★

no fast i/o is required, i have solved with segTree without fast i/o, i used offline programming

(29 Dec '14, 22:23) gvaibhav217★

hmmmm maybe I should have done more constant optimization before using fast i/o :P

(29 Dec '14, 22:32) neo1tech9_76★
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:

×1,768
×1,138

question asked: 24 Dec '14, 19:09

question was seen: 1,968 times

last updated: 29 Dec '14, 22:32