比赛 |
2024暑期C班集训1 |
评测结果 |
AAAAAAWAAAWAWAWWAWWW |
题目名称 |
雨和卡布奇诺 |
最终得分 |
60 |
用户昵称 |
┭┮﹏┭┮ |
运行时间 |
0.644 s |
代码语言 |
C++ |
内存使用 |
34.92 MiB |
提交时间 |
2024-07-01 11:07:51 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define fi first
#define db double
const int N = 2e5+10,M = 1e6+1e5;
const ll mod = 1e9+7;
ll read(){
ll x = 0,f = 1;char c = getchar();
for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
for(;c <= '9' && c >= '0';c = getchar())x = (x<<1) + (x<<3) + c-'0';
return x * f;
}
int n,m,len,ans;
int t[N],u[N],l[N],k[N],ch[N*5];
vector<int>a[N],b[N],c[N],d[N];
int cnt[N*5];
bool v[N];
void solve(){
n = read();
for(int i = 1;i <= n;i++)ch[++len] = t[i] = read(),u[i] = read();
m = read();
for(int i = 1;i <= m;i++){
l[i] = read();
for(int j = 1;j <= l[i];j++)a[i].pb(read()),ch[++len] = a[i][j-1],b[i].pb(read());
k[i] = read();
for(int j = 1;j <= k[i];j++)c[i].pb(read()),ch[++len] = c[i][j-1],d[i].pb(read());
}
sort(ch+1,ch+1+len);
len = unique(ch+1,ch+1+len) - (ch+1);
for(int i = 1;i <= n;i++)t[i] = lower_bound(ch+1,ch+1+len,t[i]) - ch;
for(int i = 1;i <= m;i++){
for(int j = 1;j <= l[i];j++)a[i][j-1] = lower_bound(ch+1,ch+1+len,a[i][j-1]) - ch;
for(int j = 1;j <= k[i];j++)c[i][j-1] = lower_bound(ch+1,ch+1+len,c[i][j-1]) - ch;
}
for(int i = 1;i <= n;i++)cnt[t[i]] = u[i];
int las = 0;
while(1){
for(int i = 1;i <= m;i++){
if(v[i])continue;
bool f = 1;
for(int j = 0;j < l[i];j++)
if(cnt[a[i][j]] < b[i][j]){f = 0;break;}
if(f){
v[i] = 1,las++;
for(int j = 0;j < k[i];j++)cnt[c[i][j]] += d[i][j];
}
}
if(ans == las)break;
ans = las;
}
printf("%d\n",ans);
}
int main(){
freopen("Cappuccino.in","r",stdin);
freopen("Cappuccino.out","w",stdout);
int t = 1;
while(t--)solve();
return 0;
}