CF730C.Bulmart
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The first line contains two integers n , m (1<=n<=5000 , 0<=m<=min(5000,n⋅(n−1)/2)) . Each of the next m lines contains two integers xe and ye , meaning that the e -th road connects cities xe and ye ( 1<=xe,ye<=n ).
The next line contains a single integer w ( 1<=w<=5000 ) — the total number of Bulmart stores in Berland. Each of the next w lines contains three integers describing the i -th store: ci,ki,pi ( 1<=ci<=n,1<=ki,pi<=2⋅105 ).
The next line contains a single integer q ( 1<=q<=1000 ) — the number of queries. Each of the next q lines contains three integers describing the j -th query: gj,rj and aj ( 1<=gj<=n , 1<=rj,aj<=109 )
输入格式
Output q lines. On the j -th line, print an answer for the j -th query — the minimum amount of time needed to deliver rj shovels to the customer in city gj spending no more than aj burles. Print -1 if there is no solution for the j -th query.
输出格式
无
输入输出样例
输入#1
6 4 4 2 5 4 1 2 3 2 2 4 1 2 3 2 3 6 1 2 6 2 3 7 3 1 2 4 3 8 5 2 5 6 1 10
输出#1
2 -1 2 2 3 -1