记录编号 |
588885 |
评测结果 |
EEEEEEEEEEEEEEEEEEEE |
题目名称 |
雨和卡布奇诺 |
最终得分 |
0 |
用户昵称 |
彭欣越 |
是否通过 |
未通过 |
代码语言 |
C++ |
运行时间 |
3.879 s |
提交时间 |
2024-07-01 19:48:06 |
内存使用 |
11.84 MiB |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
long long n,m,d[100010],mk[100010],res;
struct node {
long long a,b;
};
vector<node>a[100010];
vector<node>b[100010];
void dfs (long long ans) {
for (int i=1;i<=m;i++) {
if (mk[i]==1) continue;
int flag=0;
for (int j=0;j<a[i].size();j++) {
if (d[a[i][j].a]<a[i][j].b) {
flag=1;
break;
}
}
if (flag==0) {
for (int j=0;j<b[i].size();j++) {
d[b[i][j].a]+=b[i][j].b;
}
mk[i]=1;
//cout << i <<' '<< d[b[i][1].a] <<' '<< d[b[i][1].b] <<endl;
res=max(res,ans+1);
dfs(ans+1);
for (int j=0;j<b[i].size();i++) {
d[b[i][j].a]-=b[i][j].b;
}
mk[i]=0;
}
}
}
int main () {
freopen("Cappuccino.in","r",stdin);
freopen("Cappuccino.out","w",stdout);
cin >> n;
for (int i=1;i<=n;i++) {
int x,y;
cin >> x >> y;
d[x]=y;
}
cin >> m;
for (int i=1;i<=m;i++) {
int x,y,z;
cin >> x;
for (int j=1;j<=x;j++) {
cin >> y >> z;
a[i].push_back((node){y,z});
}
cin >> x;
for (int j=1;j<=x;j++) {
cin >> y >> z;
b[i].push_back((node){y,z});
}
}
dfs(0);
cout << res <<endl;
return 0;
}