| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 143 | 22 | 18 | 15.254% |
There are $N$ cards placed face down in a row. A positive integer less than or equal to $m$ is written on each card.
Let $A_i$ be the integer written on the $i$-th card.
Your goal is to guess $A_1, ,円 A_2, ,円 \cdots , ,円 A_N$ correctly.
The only operation you can do is:
Also, you are given the following information:
What is the minimum cost you need to pay to guess all of $A_1, ,円 A_2, ,円 \cdots , ,円 A_N$ correctly?
The first line contains three integers $N,ドル $M$ and $m$.
The second line contains $N$ integers $X_1, ,円 X_2, ,円 \cdots, ,円 X_N$.
This is followed by $M$ lines, the $i$-th line contains three integers $a_i,ドル $b_i$ and $c_i$.
If the $N$ integers written on each card can't be determined no matter how much you pay(i.e. if there's a contradiction in the information), print only -1.
Otherwise, in the first line, print a single integer — the minimum cost you need to pay to guess all of $A_i$ correctly.
In the second line, print $N$ integers $A^\prime_1, ,円 A^\prime_2, ,円 \cdots , ,円 A^\prime_N$ — one of the possibilities of $A_1, ,円 A_2, ,円 \cdots , ,円 A_N$.
5 2 7 1 2 1 3 3 1 3 6 4 5 0
6 5 2 1 3 4
You can do the operation on the first, second, and fifth cards to guess all of $A_i$ correctly. The minimum cost you have to pay is 6ドル$.
2 2 3 3 5 1 2 0 1 2 1
-1
$A_1 + A_2 \equiv 0$ and $A_1 + A_2 \equiv 1$ can't be satisfied at the same time.