比赛 |
2024暑期C班集训1 |
评测结果 |
AAAAAAAAAAAAAATTATTT |
题目名称 |
雨和卡布奇诺 |
最终得分 |
75 |
用户昵称 |
liuyiche |
运行时间 |
5.774 s |
代码语言 |
C++ |
内存使用 |
11.75 MiB |
提交时间 |
2024-07-01 09:46:47 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, ans = 0;
unordered_map<int,ll> w;
bool pd = true;
struct node
{
vector<ll> a;
vector<ll> b;
vector<ll> c;
vector<ll> d;
bool f;
int l, k;
};
node z[100005];
int main()
{
freopen("Cappuccino.in", "r", stdin);
freopen("Cappuccino.out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 1; i <= n; ++i)
{
ll t, u;
cin >> t >> u;
w[t] = u;
}
cin >> m;
for(int i = 1; i <= m; ++i)
{
z[i].f = true;
cin >> z[i].l;
for(int j = 1; j <= z[i].l; ++j)
{
ll x, y;
cin >> x >> y;
z[i].a.push_back(x);
z[i].b.push_back(y);
}
cin >> z[i].k;
for(int j = 1; j <= z[i].k; ++j)
{
ll x, y;
cin >> x >> y;
z[i].c.push_back(x);
z[i].d.push_back(y);
}
}
for(int i = 1; i <= m; ++i)
{
if(pd == false)
break;
for(int j = 1; j <= m; ++j)
{
if(z[j].f == false)
continue;
bool flag = true;
for(int k = 0; k < z[j].l; ++k)
{
if(w[z[j].a[k]] < z[j].b[k])
{
flag = false;
break;
}
}
if(flag == false)
continue;
ans++;
for(int k = 0; k < z[j].k; ++k)
w[z[j].c[k]] += z[j].d[k];
z[j].f = false;
}
}
cout << ans;
return 0;
}