[Huawei OD machine test 2023 latest] Static scanning / using a reasonable cache strategy, the minimum number of gold coins required (C language problem solution 100%)

topic description

Static scanning can quickly identify defects in source code, and the result of static scanning is output as a scanning report:

1. The cost of file scanning is related to the file size. If the file size is N, the scanning cost is N gold coins

2. The cache cost of the scan report has nothing to do with the file size. Each cached report requires M gold coins

3. After scanning the report cache, if you encounter this file later, you don’t need to scan the cost, and you can directly get the cached result

Given the source code file identification sequence and file size sequence, solve the minimum number of gold coins required by using a reasonable cache strategy.

enter description

The first line caches a report of the number of gold coins M, L<= M <= 100

The second line identifies the sequence of files: F1, F2, F3, ..., Fn.

The third line is a sequence of file sizes: S1,S2,S3,...,Sn.

Remark:

  • 1 <= N <= 10000
  • 1 <= Fi <= 1000
  • 1 <= Si <= 10

output description

use

Guess you like

Origin blog.csdn.net/shangyanaf/article/details/130484828