Clash!
의견: 0
Farmer John is playing a famous and strategic card game with his dear cow
Bessie. FJ has \(N\) (\(2\le N\le 2\cdot 10^5\)) cards, conveniently numbered from
\(1\) to \(N\). The \(i\)'th card costs \(a_i\) (\(1 \leq a_i \leq 10^9\)) moolixir if FJ
wants to play it.
His hand always consists of \(H\) cards at any given time (\(1\le H
his hand consists of cards \(1\) through \(H\). The remaining cards are in a draw
queue. Every time FJ plays a card in his hand, he will draw its replacement from
the front of the draw queue to his hand. Then, FJ will put the card he just
played to the back of the draw queue. Initially, cards \(H+1\) through \(N\) are
arranged from the front to the back of the draw queue in that order.
In this game, time is measured in integer seconds. Initially, the game starts at
time \(0\) with FJ having \(0\) moolixir. Immediately before each of integer times
\(t=1,2,3,\dots,\) moolixir increases by \(1\). At each integer time, FJ may choose
to play a card in his hand if its cost does not exceed FJ's current moolixir
count, which subtracts FJ's current moolixir count by the card's cost.
FJ marks a subset of his cards \(s_1, s_2, \ldots, s_k\) as win-conditions
(\(1\le k\le N\), \(1\le s_i\le N\)). If FJ has at least one win-condition in his
hand, the next card he plays must be a win-condition.
He asks you \(Q\) (\(1 \leq Q \leq 2 \cdot 10^5\)) queries. Each query is of the
following form: what is the maximum number of win-conditions he could have
placed down within \(t\) time (\(1 \leq t \leq 10^{18}\))?
Problem credits: Chongtian Ma
SCORING
- Inputs 2-3: \(N,Q\le 100\)
- Inputs 4-5: \(H=1\)
- Inputs 6-11: No additional constraints.
Problem credits: Chongtian Ma
The first line contains \(N\) and \(H\).
The second line contains \(N\) integers \(a_1, a_2, \ldots, a_N\).
The third line contains an integer \(k\), the number of win-conditions.
The fourth line contains \(k\) distinct integers
\(s_1, s_2, \ldots, s_k\).
The fifth line contains an integer \(Q\).
The following \(Q\) lines each contain an integer \(t\), the time to answer for each
query.
For each query, output the maximum number of win-conditions that FJ could've put
down within \(t\) time.
6 3
2 4 3 5 7 6
2
1 4
6
1
2
3
7
10
10000000000000000
1
1
2
2
142857142857143In this case, you start with card 1, a win condition on your hand. You can play
it after you accumulate 2 elixir in 2 seconds. This means that just after t=1
you can play no cards, but after t=2 you can play your first card, which must
be your win condition.
After t=3, it is still most optimal to play card 1 and have 1 elixir remaining,
so the answer here is still 1.
You then draw card 4, which is also a win condition. You play it immediately
after t=7, so you have played 2 win conditions at this time.
You then draw card 5 and have no win conditions in your hand. After t=10, even
if you play card 3 with the 3 elixir you have, your number of win conditions
does not change.
riseoj 작성
출처 올림피아드 > USACO > 2025-2026 > Third Contest > Silver
평가 및 의견
Clash!
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Clash!