P2535 [AHOI2012] Collect Resources

Description

![](https://cdn.luogu.com.cn/upload/pic/1637.png) ![](https://cdn.luogu.com.cn/upload/pic/1638.png)

Input Format

![](https://cdn.luogu.com.cn/upload/pic/1639.png)

Output Format

![](https://cdn.luogu.com.cn/upload/pic/1640.png)

Explanation/Hint

Constraints: - 50%: $1 \le N, M, T \le 100$. - 100%: $1 \le N, M, T \le 200$. Translated by ChatGPT 5