0
1

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.

yukicoder contest 247 参戦記

Last updated at Posted at 2020-05-08

yukicoder contest 247 参戦記

A 1046 Fruits Rush

正の新鮮さの果物があるのであれば、正の新鮮さの果物だけ大きい方から順にK個採用する(K個無い場合は全部). 0以下の果物しか無いのであれb、一番0に近いやつを1つだけ採用する.

N, K = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)
print(A[0] + sum([a for a in A[1:] if a > 0][:K - 1]))

B 1047 Zero (Novice)

分からないので、多めにループを回して0になるかどうか確認するだけのコードを書いたら AC した(酷い). A, B が大きいので、105 回したら TLE します.

A, B = map(int, input().split())

N = 0
for i in range(1, 10000):
    N = A * N + B
    if N == 0:
        print(i)
        exit()
print(-1)

C 1048 Zero (Advanced)

K回の操作後の N は L * K <= N <= R * K になる. R * K 以下の最大の M の倍数が A 以上であれば N = 0 となるような操作列が存在することになる. A が L * K、B が R * K のときの ABC165A - We Love GolfO(1) で解く問題です(笑).

L, R, M, K = map(int, input().split())

if R * K // M * M >= L * K:
    print('Yes')
else:
    print('No')
0
1
0

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?