当前位置:网站首页>hdu 2647 Reward(拓扑排序)
hdu 2647 Reward(拓扑排序)
2022-08-09 18:34:00 【51CTO】
题目: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=23269
Description
Dandelion's uncle is a boss of a factory. As the spring festival is coming , he wants to distribute rewards to his workers. Now he has a trouble about how to distribute the rewards.
The workers will compare their rewards ,and some one may have demands of the distributing of rewards ,just like a's reward should more than b's.Dandelion's unclue wants to fulfill all the demands, of course ,he wants to use the least money.Every work's reward will be at least 888 , because it's a lucky number.
Input
One line with two integers n and m ,stands for the number of works and the number of demands .(n<=10000,m<=20000)
then m lines ,each line contains two integers a and b ,stands for a's reward should be more than b's.
Output
For every case ,print the least money dandelion 's uncle needs to distribute .If it's impossible to fulfill all the works' demands ,print -1.
Sample Input
2 1 1 2 2 2 1 2 2 1
Sample Output
1777 -1
让最小的人收到888money,比他大的加1,按照拓扑排序增长,最后求出总资金。
边栏推荐
猜你喜欢
随机推荐
字节二面:可重复读隔离级别下,这个场景会发生什么?
环境:Flink版本:1.15.1jar包:flink-sql-connector-oracle
Paper sharing: "FED BN" uses the LOCAL BATCH NORMALIZATION method to solve the Non-iid problem
超多AI开发者等你来玩转,一起燃动昇腾AI创享日南京站!
优秀的 Verilog/FPGA开源项目介绍(三十一)- OFDM
Openharmony轻量系统实验--GPIO点灯
uniapp离线推送华为厂商申请流程
pat链表专题训练+搜索专题
数学建模代码速成~赛前一个月~matlab~代码模板~吐血总结~三大模型代码(预测模型、优化模型、评价模型)
How to stop the test after reaching a given number of errors during stress testing in JMeter
Intensive reading of the paper: VIT - AN IMAGE IS WORTH 16X16 WORDS: TRANSFORMERS FOR IMAGE RECOGNITION AT SCALE
MFC教程
[免费专栏] Android安全之ZIP文件目录遍历漏洞
Linux上给PHP安装redis扩展
web正则表达式中^和$的含义是什么
工大科雅深交所上市:市值45亿 齐承英家族是大股东
一图详解沃土云创计划高校教师参与全流程
论文精读:VIT - AN IMAGE IS WORTH 16X16 WORDS: TRANSFORMERS FOR IMAGE RECOGNITION AT SCALE
[Free Column] Android Security for Peace Elite (FZ) APK Reverse Analysis
MQTT X Web:在线的 MQTT 5.0 客户端工具