Logo
(追記) (追記ここまで)

24411번 - Stamp Combinations 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
7 초 1024 MB151443936.449%

문제

You’re on your way to pick up a package from the store, wrap it, and mail it. You want to bring a certain number of stamps to mail it, and you have a long roll of stamps that you can use. Now, over time, you’ve occasionally pulled off a stamp from somewhere in the middle of the roll, and now you’re left with a strip where stamps are clustered in groups, separated by empty spaces.

Being practical, you don’t want to tear individual stamps, and so you’ll only tear the roll in between the clusters of stamps. And, you don’t want to be left with multiple rolls of stamps, so you can only pull these groups off of the beginning or end of the roll. Is it possible to do this with the roll of stamps you have?

입력

The first line of input consists of two integers, $m$ and $n,ドル 1ドル ≤ m, n ≤ 10^6,ドル 1ドル ≤ m \cdot n ≤ 10^7,ドル giving the number of clusters of stamps and the number of queries you will have.

The second line contains $m$ integers, $a_i,ドル 1ドル ≤ a_i ≤ 100,ドル separated by spaces. These give the number of stamps in each cluster, in order from the beginning to the end of the roll.

The next $n$ lines each contain one integer, $q,ドル 0ドル ≤ q ≤ 10^8,ドル giving a query, where a query is the number of stamps needed to mail a package.

출력

For each query, output one line containing “Yes” if it is possible to bring that number of stamps, or ‘No” if it is not possible to bring that number of stamps.

제한

예제 입력 1

5 5
2 8 1 3 3
2
10
5
17
1

예제 출력 1

Yes
Yes
Yes
Yes
No

힌트

The roll contains 5ドル$ clusters of stamps.

A group of 2ドル$ stamps can be taken by tearing just the first cluster of stamps off of the roll.

A group of 10ドル$ stamps can be taken by tearing the first two clusters of stamps off of the roll.

A group of 5ドル$ stamps can be taken by tearing the first cluster (of 2ドル$) and the last cluster (of 3ドル$) off of the roll.

A group of 17ドル$ stamps can be taken by taking the entire roll.

It is not possible to take just 1ドル$ stamp, since tearing the roll to take the single stamp in the middle of the roll would not leave you with a single roll of stamps, and it is not possible to tear in the middle of a cluster.

출처

ICPC > Regionals > North America > North America Qualification Contest > ICPC North America Qualifier 2021 K번

  • 문제를 만든 사람: John Keyser
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /