凑巧,就用了个HashMap
最后遍历hashmap一趟,大于则++。

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Mainh {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String[] line1 = scanner.nextLine().split(" ");
            int target = Integer.valueOf(line1[2]);
            String[] remain = scanner.nextLine().split(" ");
            HashMap<Integer, Integer> hashMap = new HashMap<>();
            for (int i = 0; i < remain.length; i++) {
                hashMap.put(i+1,Integer.valueOf(remain[i]));
            }
            int nextLines = Integer.valueOf(line1[1]);
            String tmp;
            int key;
            while (nextLines > 0){
                tmp = scanner.nextLine();
                key = Integer.valueOf(tmp.split(" ")[1]);
                if (tmp.contains("A")){
                    hashMap.put(key, hashMap.get(key) + 1);
                }else hashMap.put(key, hashMap.get(key) - 1);
                nextLines--;
            }
            int topK = 1;
            int targetValue = hashMap.get(target);
            for (Map.Entry<Integer, Integer> entry : hashMap.entrySet()) {
                if (Integer.valueOf(entry.getValue()) > targetValue){
                    topK += 1;
                }
            }
            System.out.println(topK);
        }
    }
}
/*

3 4 2
5 3 1
B 1
A 2
A 2
A 3

*/