Блог пользователя one0one

Автор one0one, история, 5 лет назад, По-английски

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?

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор one0one, история, 6 лет назад, По-английски

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?

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор one0one, история, 7 лет назад, По-английски

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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится