ç´ æ´ãª map
ã®ç·´ç¿åé¡
åé¡æ¦è¦
ããããã㯠åã®åé¡æ¡ãæã£ã¦ããã åç®ã®åé¡æ¡ã®é£æ度㯠ã§ããã
ãããããé ç¹ã ã§ãããã㪠åãããªãåé¡ã»ãããä½ããã¨ã¯å¯è½ãï¼
å¶ç´
èãããã¨
é£æ³é
å (C++ ãªãã° map
) ã®ç·´ç¿åé¡ã次ã®ãããªé£æ³é
åãç¨æãããã
problems[x]
ï¼æ®ã£ã¦ããåé¡æ¡ã®ä¸ã«ãé ç¹ ã®åé¡ã¯ä½åãããï¼
ãããã¦ã ã«å¯¾ãã¦ãproblems[T[i]]
ã®å¤ã 1 æ¸ããã¦ããã°è¯ããéä¸ã§è² ã®å¤ã«ãªã£ããä¸å¯è½ã ã¨ãããã
è¨ç®é㯠ã¨ãªãã
ã³ã¼ã
#include <bits/stdc++.h> using namespace std; int main() { int N, M, D, T; cin >> N; map<int, int> problems; for (int i = 0; i < N; i++) { cin >> D; problems[D]++; } cin >> M; bool res = true; for (int i = 0; i < M; i++) { cin >> T; problems[T]--; if (problems[T] < 0) res = false; } cout << (res ? "YES" : "NO") << endl; }