시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
3 초 | 2048 MB | 95 | 32 | 24 | 32.877% |
JOI, Ltd. is a company known for their “just odd inventions.” Recently, JOI, Ltd. developed a text editor called “Just Odd Editor.”
Using this text editor, we can input a string of characters by performing the following operations several times. Let $X$ be the string displayed on the screen of the text editor. Let $Y$ be the string saved in the clipboard. In the beginning, both of $X$ and $Y$ are the empty string.
Here, for characters or strings $x$, $y$, the string $x + y$ means the string obtained by connecting $x$ with $y$ in this order. Performing an operation takes time. If we perform the operation $A$, $B$, $C$ once, it takes $A$, $B$, $C$ unit time, respectively.
You installed Just Odd Editor. You want to input a string $S$ of length $N$ as soon as possible. Performing operations, you want to make the string on the display be $S$ as soon as possible.
Write a program which, given the length $N$, the string $S$, and the amount of unit time needed to perform an operation, calculates the least amount of time needed to input the string $S$.
Read the following data from the standard input.
$\begin{align*} & N \\ & S \\ & A \\ & B \\ & C\end{align*}$
Write one line to the standard output. The output should contain the least amount of time needed to input the string $S$.
a
' - 'z
').번호 | 배점 | 제한 |
---|---|---|
1 | 1 | $N = 3$. |
2 | 5 | Every character of $S$ is ' |
3 | 14 | $N ≤ 30$. |
4 | 10 | $N ≤ 200$. |
5 | 32 | $N ≤ 1\,000$. |
6 | 38 | No additional constraints. |
11 mississippi 10 5 2
88
By performing the following operations, we can input mississippi
by $88$ unit time. Since it is the least amount of time needed to input mississippi
, output $88$.
Order | Operation | Explanation | $X$ | $Y$ | Time | Total Time |
---|---|---|---|---|---|---|
- | - | - | "" |
"" |
- | $0$ |
1 | Operation A | Add a character in end | "s" |
"" |
$10$ | $10$ |
2 | Operation B | Select all & Cut | "" |
"s" |
$5$ | $15$ |
3 | Operation C | Paste at end | "s" |
"s" |
$2$ | $17$ |
4 | Operation C | Paste at end | "ss" |
"s" |
$2$ | $19$ |
5 | Operation A | Add a character in end | "ssi" |
"s" |
$10$ | $29$ |
6 | Operation B | Select all & Cut | "" |
"ssi" |
$5$ | $34$ |
7 | Operation A | Add a character in end | "m" |
"ssi" |
$10$ | $44$ |
8 | Operation A | Add a character in end | "mi" |
"ssi" |
$10$ | $54$ |
9 | Operation C | Paste at end | "missi" |
"ssi" |
$2$ | $56$ |
10 | Operation C | Paste at end | "mississi" |
"ssi" |
$2$ | $58$ |
11 | Operation A | Add a character in end | "mississip" |
"ssi" |
$10$ | $68$ |
12 | Operation A | Add a character in end | "mississipp" |
"ssi" |
$10$ | $78$ |
13 | Operation A | Add a character in end | "mississippi" |
"ssi" |
$10$ | $88$ |
This sample input satisfies the constraints of Subtasks 3, 4, 5, 6.
16 aaaaaaaaaaaaaaaa 1 1 1
9
By performing the following operations, we can input aaaaaaaaaaaaaaaa
by $9$ unit time. Since it is the least amount of time needed to input aaaaaaaaaaaaaaaa
, output $9$.
Order | Operation | Explanation | $X$ | $Y$ | Time | Total Time |
---|---|---|---|---|---|---|
- | - | - | "" |
"" |
- | $0$ |
1 | Operation A | Add a character in end | "a" |
"" |
$1$ | $1$ |
2 | Operation A | Add a character in end | "aa" |
"" |
$1$ | $2$ |
3 | Operation A | Add a character in end | "aaa" |
"" |
$1$ | $3$ |
4 | Operation A | Add a character in end | "aaaa" |
"" |
$1$ | $4$ |
5 | Operation B | Select all & Cut | "" |
"aaaa" |
$1$ | $5$ |
6 | Operation C | Paste at end | "aaaa" |
"aaaa" |
$1$ | $6$ |
7 | Operation C | Paste at end | "aaaaaaaa" |
"aaaa" |
$1$ | $7$ |
8 | Operation C | Paste at end | "aaaaaaaaaaaa" |
"aaaa" |
$1$ | $8$ |
9 | Operation C | Paste at end | "aaaaaaaaaaaaaaaa" |
"aaaa" |
$1$ | $9$ |
This sample input satisfies the constraints of Subtasks 2, 3, 4, 5, 6.
18 aababbbababbbaabbb 1000000000 100000 10000000
8060200000
This sample input satisfies the constraints of Subtasks 3, 4, 5, 6.
Camp > JOI Spring Training Camp > JOI 2021/2022 Spring Training Camp 2-1번
Camp > JOIG Spring Training Camp > JOIG 2021/2022 Spring Training Camp 1-4번