Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ________ _______ ______ _______ ________
- /_______/\ /_______/\ /_____/\ /_______/\ /_______/\
- \::: _ \ \\::: _ \ \\:::_ \ \\::: _ \ \\::: _ \ \
- \::(_) \ \\::(_) \/_\:\ \ \ \\::(_) \/_\::(_) \ \
- \:: \ \\:: _ \ \\:\ \ \ \\:: _ \ \\:: \ \
- \:.\ \ \ \\::(_) \ \\:\_\ \ \\::(_) \ \\:.\ \ \ \
- \__\/\__\/ \_______\/ \_____\/ \_______\/ \__\/\__\/
- */
- #include <iostream>
- #include <string>
- #include <sstream>
- #include <vector>
- #include <cmath>
- #include <algorithm>
- #include <memory.h>
- #include <stdio.h>
- #include <stack>
- #include <deque>
- #include <queue>
- #include <set>
- #include <iterator>
- #include <map>
- #include <iomanip>
- #include <unordered_set>
- #define int long long
- #define pb push_back
- #define double long double
- #define endl "\n"
- #define un unsigned
- #define INF 1000000007
- #define pii pair<int, int>
- #define all(v) v.begin(), v.end()
- using namespace std;
- const int N = 1000000;
- const int MOD = 1e9 + 7;
- signed main()
- {
- ios_base::sync_with_stdio();
- cin.tie(0);
- cout.tie(0);
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- int m;
- cin >> m;
- map<string, int> mp;
- for (int i = 0; i < m; i++)
- {
- string s;
- int a;
- cin >> s >> a;
- mp[s] = a;
- }
- int n;
- cin >> n;
- map<string, map<string, int>> rec;
- for (int i = 0; i < n; i++)
- {
- string s;
- cin >> s;
- int a;
- cin >> a;
- for (int j = 0; j < a; j++)
- {
- string kok;
- int lol;
- cin >> kok >> lol;
- rec[s][kok] = lol;
- }
- }
- int k;
- cin >> k;
- int ans = 0;
- for (auto ff = rec.begin(); ff != rec.end(); ff++)
- {
- bool flag = 1;
- auto lool = (*ff).first;
- for (auto kek : rec[lool])
- {
- if (kek.second > mp[kek.first])
- {
- flag = 0;
- }
- }
- ans += flag;
- }
- cout << ans << endl;
- for (int i = 0; i < k; i++)
- {
- string s;
- cin >> s;
- for (auto& j : rec[s])
- {
- auto lol = j.second;
- mp[j.first] -= lol;
- }
- int ans = 0;
- for (auto ff = rec.begin(); ff != rec.end(); ff++)
- {
- bool flag = 1;
- auto lool = (*ff).first;
- for (auto kek : rec[lool])
- {
- if (kek.second > mp[kek.first])
- {
- flag = 0;
- }
- }
- ans += flag;
- }
- cout << ans << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement