0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

はじめ

前回
今日からC。書くの忘れていたので一問だけです。

#15

問題

考えたこと
昨日のB問題の類題です。forループを3つから2つに減らすことでTLEを防いでいます。

n ,y = map(int,input().split())

for i in range(n+1):
    for j in range(n+1):
        noguti = (y - (i * 10000 + j * 5000)) // 1000
        if noguti + i + j == n and noguti >= 0:
            print(i,j,noguti)
            quit()

print(-1,-1,-1)

ちなみに、Python3→1567ms、PyPy3→276msでした。PyPyつよい

まとめ

昨日の類題だったので、すぐにできた。Python3とPyPy3で結構な速度差があるので、for文使うのはPyPyを使ったほうがいいかな。では、また

0
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?