RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0702

Clash!

Silver II 실버 II
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 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). Initially,
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.

예제 1
입력
6 3
2 4 3 5 7 6
2
1 4
6
1
2
3
7
10
1000000000000000
출력
0
1
1
2
2
142857142857143
설명

In 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!

개요
출제자 난이도 Silver II 실버 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Clash!

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8