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

19404번 - Distribution of Prize Money 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB288836.364%

문제

The most famous Zurumbian programming contest, Zurumbia Open, has been recently held online. The total prize fund of the contest is $x$ Zurumbian roubles!

There were $n$ contestants taking part, and each of them was ranked from 1-st to $n$-th. No two contestants had the same rank.

Unfortunately, the distribution of prize money among the contestants is not known yet. It's only known that every contestant will receive a non-negative integer amount of Zurumbian roubles, and no contestant will receive less money than another contestant with greater rank.

Some of the contestants are your friends. You've decided to find the least possible part of the prize fund which will be definitely received by them in total, among all valid distributions of prize money. Also, you are interested in the worst distribution --- that is, the one that leads to the least possible amount of money received by your friends. Write a program to help yourself.

입력

The first line of the input contains a single integer $x$ (1ドル \le x \le 10^9$) --- the total prize fund, in Zurumbian roubles. The second line contains a string of length $n$ (1ドル \le n \le 400$) consisting of uppercase English letters "Y" and "N" only. The $i$-th (1-based) character of the string equals to "Y" if the contestant ranked $i$-th is your friend, and "N" otherwise.

출력

Output two lines.

The first line must contain the least possible amount of money, in Zurumbian roubles, which will be definitely received by your friends in total.

The second line must contain a non-increasing sequence of $n$ non-negative integers --- the prizes of the contestants ranked first, second, $\ldots,ドル $n$-th in the worst distribution of prize money. The sum of these $n$ integers must be equal to $x$. If there are several worst distributions, you may output any of them.

제한

예제 입력 1

23
YNYNNYY

예제 출력 1

10
7 7 3 3 3 0 0

힌트

In the distribution from the example test case, your friend ranked first will receive 7 Zurumbian roubles, the third-ranked one will receive 3 Zurumbian roubles, and two other friends will receive nothing, resulting in the grand total of 10 Zurumbian roubles received by your friends. It can be proved that in any distribution of prize money, your friends will always receive at least 10 Zurumbian roubles.

출처

Camp > Petrozavodsk Programming Camp > Winter 2017 > Day 6: Gennady Korotkevich Contest 2, Head of Republic of Karelia Cup, Round II D번

Contest > Open Cup > 2016/2017 Season > Stage 10: Grand Prix of Gomel D번

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

출처

대학교 대회

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

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