아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Distribution of Prize Money

시간 제한2초메모리 제한512 MB

요약
상금 총액과 친구 표시 문자열이 주어질 때 친구들이 반드시 받는 최소 총액을 구하고, 그 최소를 만드는 비증가 상금 배분 하나를 출력한다.
난이도

보통10점 중 6점

유형
그리디, 동적 계획법, 수학
정답자
아직 제출이 없습니다

문제

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

There were nn contestants taking part, and each of them was ranked from 1-st to nn-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 xx (1≤x≤1091 \le x \le 10^9) --- the total prize fund, in Zurumbian roubles. The second line contains a string of length nn (1≤n≤4001 \le n \le 400) consisting of uppercase English letters "Y" and "N" only. The ii-th (1-based) character of the string equals to "Y" if the contestant ranked ii-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 nn non-negative integers --- the prizes of the contestants ranked first, second, …\ldots, nn-th in the worst distribution of prize money. The sum of these nn integers must be equal to xx. If there are several worst distributions, you may output any of them.

힌트

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.

예제1

  1. 예제 1

    입력
    23
    YNYNNYY
    
    예상 출력
    10
    7 7 3 3 3 0 0