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

It's Mooin' Time

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

의견: 0

설명

*Note: The time limit for this problem is 3s, 1.5x the default.*

Bessie has a string of length \(N\) (\(1\le N\le 3\cdot 10^5\)) consisting solely of
the characters M and O. For each position \(i\) of the string, there is a cost
\(c_i\) to change the character at that position to the other character
(\(1\le c_i\le 10^8\)).

Bessie thinks the string will look better if it contains more moos of length \(L\)
(\(1\le L\le \min(N, 3)\)). A moo of length \(L\) is an M followed by \(L-1\) Os.

For each positive integer \(k\) from \(1\) to \(\lfloor N/L\rfloor\) inclusive,
compute the minimum cost to change the string to contain at least \(k\) substrings
equal to a moo of length
\(L\).

Problem credits: Benjamin Qi

제약

SCORING

  • Input 5: \(L=3, N\le 5000\)
  • Input 6: \(L=1\)
  • Inputs 7-10: \(L=2\)
  • Inputs 11-18: \(L=3\)

Problem credits: Benjamin Qi

입력 형식

The first line contains \(L\) and \(N\).

The next line contains Bessie's length-\(N\) string, consisting solely of Ms and
Os.

The next line contains space-separated integers \(c_1\dots c_N\).

출력 형식

Output \(\lfloor N/L\rfloor\) lines, the answer for each \(k\) in increasing order.

예제 1
입력
1 4
MOOO
10 20 30 40
출력
0
20
50
90
예제 2
입력
3 4
OOOO
50 40 30 20
출력
40
예제 3
입력
2 20
OOOMOMOOOMOOOMMMOMOO
44743602 39649528 94028117 50811780 97338107 30426846 94909807 22669835 78498782 18004278 16633124 24711234 90542888 88490759 12851185 74589289 54413775 21184626 97688928 10497142
출력
0
0
0
0
0
12851185
35521020
60232254
99881782
952304708
예제 4
입력
3 20
OOOMOMOOOMOOOMMMOMOO
44743602 39649528 94028117 50811780 97338107 30426846 94909807 22669835 78498782 18004278 16633124 24711234 90542888 88490759 12851185 74589289 54413775 21184626 97688928 10497142
출력
0
0
0
44743602
119332891
207066974
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2024-2025 > December > Platinum

태그

평가 및 의견

It's Mooin' Time

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

Log in to rate problems.

개별 의견

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

풀이 제출

It's Mooin' Time

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