比赛 |
2024暑期C班集训1 |
评测结果 |
AAWAWWWAWWWAWWTTTTTT |
题目名称 |
雨和卡布奇诺 |
最终得分 |
25 |
用户昵称 |
wzh0425 |
运行时间 |
6.261 s |
代码语言 |
C++ |
内存使用 |
7.83 MiB |
提交时间 |
2024-07-01 11:27:43 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
long long n,t[200005],u[200005],m,l[100005],k[100005],st1[100005],st2[100005];
long long a[100005],b[100005],c[100005],d[100005],tm1,tm2;
long long flag,f[100005],ans;
int main(){
freopen("Cappuccino.in","r",stdin);
freopen("Cappuccino.out","w",stdout);
scanf("%d",&n);
for (long long i=1;i<=n;i++) scanf("%d%d",&t[i],&u[i]);
scanf("%d",&m);
st1[1]=1,st2[1]=1;
for (long long i=1;i<=m;i++){
scanf("%d",&l[i]);
for (long long j=1;j<=l[i];j++){
tm1++;
scanf("%d%d",&a[tm1],&b[tm1]);
}
st1[i+1]=st1[i]+l[i];
scanf("%d",&k[i]);
for (long long j=1;j<=k[i];j++){
scanf("%d%d",&c[++tm2],&d[tm2]);
}
st2[i+1]=st2[i]+k[i];
}
long long ez=n;
while (1){
flag=0;
for (long long i=1;i<=m;i++){
if (f[i]==0){
long long tmm=0;
for (long long j=st1[i];j<st1[i+1];j++){
for (long long jj=1;jj<=ez;jj++){
if (a[j]==t[jj]&&b[j]<=u[jj]){
tmm++;
break;
}
}
}
if (tmm==st1[i+1]-st1[i]){
f[i]=-1;
flag=1;
ans++;
for (long long j=st2[i];j<st2[i+1];j++){
long long flag2=0;
for (long long jj=1;jj<=ez;jj++){
if (c[j]==t[jj]){
u[jj]+=d[j];
flag2=1;
break;
}
}
if (flag2==0){
t[++ez]=c[j];
u[ez]=d[j];
}
}
}
}
}
if (flag==0) break;
}
printf("%d",ans);
return 0;
}