Buy and Delete
시간 제한2초메모리 제한1024 MB
앨리스가 예산 c 안에서 방향 간선을 사서 그래프에 넣으면, 밥이 비순환 부분집합을 한 라운드씩 지워 그래프를 비우는데, 두 사람이 최적으로 둘 때 필요한 라운드 수를 구한다.
문제
Alice and Bob are playing a game on a directed graph . There are vertices in , labeled by . Initially, there are no edges in . Alice will first buy some direct edges from the shop and then add them into . After that, Bob needs to delete edges until there are no edges in . In a deletion round, Bob can delete a subset of edges from , such that when only keeping edges in , the graph is acyclic. Note that Alice can buy nothing, and in such a case the number of deletion rounds is .
There are edges in the shop. Alice has dollars, so the total price of edges she will buy should not exceed . Alice wants to maximize the number of deletion rounds while Bob wants to minimize it. Both Alice and Bob will play optimally. Please write a program to predict the number of deletion rounds.
입력
The input contains only a single case.
The first line of the input contains three integers and (, , ), denoting the number of vertices in , the number of edges in the shop, and how many dollars Alice has.
In the next lines, the -th line contains three integers and (, , ), denoting a directed edge in the shop. Alice can pay dollars to buy it, and add an edge from vertex to vertex in .
출력
Print a single line containing an integer, denoting the number of deletion rounds.