Alice and Bob find out a new, cool king game to play, and they want to play the game with you. You will enjoy the game, right?
Alice and Bob will give you two integer sequences
Alice and Bob allow you to do the following operations for many(possibly zero) times:
Now, they will give you
Please write a program to help them calculate the answers (minimum dollar that they have to spend).
小 A 和小 B 最近發現一個酷酷的國王遊戲,他們想和你一起玩。
他們會給你兩個整數序列
你可以做以下操作任意多次(可以不做)
現在,他們將對你詢問
請寫一個程式幫幫他們計算答案 (最少需要花多少錢)
The first line of the input contains two integers
The second line contains
The third line contains
In the following
The meanings of the parameters above have been explained in the problem statement.
輸入第一行有兩個整數
第二行有
第三行有
接下來
各個參數的意義皆在題目中有解釋
For each query, print the answer to the query in one line.
對於每筆詢問,請各自輸出一行整數代表答案
2021 台清交程式競賽 pK
No. | Testdata Range | Score |
---|---|---|
1 | 0~37 | 100 |