one0one's blog

By one0one, history, 5 years ago, In English

http://mirror.codeforces.com/contest/1196/submission/60503250 Got wrong answer

q = int(input())
 
for i in range(q):
	piles = [int(i) for i in input().split()]
	piles.sort()
	print(piles[1] + int((piles[2] - (piles[1] - piles[0])) / 2))

http://mirror.codeforces.com/contest/1196/submission/60503474 Got accepted

q = int(input())
 
for i in range(q):
	piles = [int(i) for i in input().split()]
	piles.sort()
	print(piles[1] + ((piles[2] - (piles[1] - piles[0])) // 2))

In my opinion, they do the same work but results are not the same. There is a difference between // operator and int() probably. I searched it but could not find anything. Does anyone know it?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By one0one, history, 6 years ago, In English

Hello, I tried segment tree with lazy propagation on this problem. Implementation is taken from this article. I got TLE on test#7.

In my opinion, my solution is nlog(n). updateRange works in log(n) time and I call it q times hence qlog(n). Then I call n times queryRange, it's runtime also log(n) hence nlog(n). Overall complexity is nlog(n) + qlog(n). It should work well in given constraints but unfortunately I got TLE.

So what I am missing?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By one0one, history, 7 years ago, In English

Currently, I am researching about range minimum query. I read the topcoder article. At the end of the article there is an <O(n), O(1)> solution for the restricted RMQ.

I didn't understand the article and I have googled it but what I have found was too complex for me. I am a newbie so I need some simple explanations or sources.

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it