首页 > 其他 > 详细

C. New Year Book Reading

时间:2019-08-26 13:45:22      阅读:102      评论:0      收藏:0      [点我收藏+]

 

http://codeforces.com/contest/500/problem/C

 

模拟

 

 1 import java.util.Scanner;
 2 
 3 public class Main {
 4 
 5     public static void main(String[] args) {
 6         Scanner io = new Scanner(System.in);
 7         int n = io.nextInt(), m = io.nextInt();
 8         int[] w = new int[n + 1], b = new int[n + 1];
 9         for (int i = 1; i <= n; i++) {
10             w[i] = io.nextInt();
11             b[i] = -1;
12         }
13         int ans = 0;
14         for (int i = 0, a; i < m; i++) {
15             a = io.nextInt();
16             for (int j = 1; j <= n; j++) if (b[j] > b[a]) ans += w[j];
17             b[a] = i;
18         }
19         System.out.println(ans);
20     }
21 
22 }

 

C. New Year Book Reading

原文:https://www.cnblogs.com/towerbird/p/11410177.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!