题解 P1113 【杂务】
尹昕20160508 · · 题解
一定要用。。。。。。
#include<iostream>
#include<cstdio>
#include<cstring>//无聊定这么多
using namespace std;
int main(){
int t[10001],n,ans=0,k,num,ti,x,y,i;//定这么一大坨东西
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d%d",&k,&ti);
t[k]=ti;
scanf("%d",&x);
while(x!=0){
t[k]=max(t[k],ti+t[x]);
ans=max(ans,t[k]);//更新操作
scanf("%d",&x);
}
}
printf("%d",ans);
return 0;
}