解答例コードがある問題なので、特に意味はないのですがおぼえがきに

import java.util.*;
public class Main {
public static void main(String[] args) {
// 自分の得意な言語で
// Let's チャレンジ!!
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
HashMap<String, Integer> hoges = new HashMap<>();
for(int i=0;i<num; i++){
String name = sc.next();
int damage = 0;
hoges.put(name,damage);
}
int attack_num = sc.nextInt();
for(int i=0; i<attack_num; i++){
String hogestr = sc.next();
int hogeint = sc.nextInt();
int newhogeint = hoges.get(hogestr) + hogeint;
hoges.put(hogestr,newhogeint);
}
String targetName = sc.next();
System.out.println(hoges.get(targetName));
//String line = sc.nextLine();
//System.out.println(Arrays.toString(hoges));
}
}
https://paiza.jp/works/mondai/c_rank_level_up_problems/c_rank_dictionary_step2
paiza問題集
0