暑假集训第二场

Problem B. Dating With Girls
Input le: stdin
Output le: stdout
Time limit: 2 seconds
If you have a date with a pretty girl in a hurry, you can ignore what I will say next.
Hellis is a little bad guy in Rural Small Technical College. And the most important fact is that he is
especially fond of glaring at pretty girls! And as we all know, there are some girls he favors in the same
school. So there comes the trouble. On one terrible day, it should rains. The girls all are being di erent
places. They all phone him and ask the boy to deliver them umbrellas at the same time. However, the
cute boy faces the embarrassing condition. You can have a simple Understanding that each girl has a
special relationship with our sunny boy. If they know the boy sends the umbrella to anyone of them, the
others may go mad and that is not the boy expects. If that happens, Of course you will never see that
he is completing again. But the fact is some girls are so beautiful and he would like to give them help.
The trouble is this guy wants to meet more beautiful girls before he arrives at anyone who phones him
for help. It is just a disaster, he thinks. Eventually, he makes the choice. He will just send an umbrella
to only one girl who is most important to him, and he can not be seen by other girls who phones him
for help. If that happens, I can only say hehe. He must pass these girls. In the process, he can send
beautiful girls their umbrellas! In that case, he can create a chance to communicate with them and just
win their favorable impression. It is such a good idea!
There are n di erent places in our problem. There are m di erent undirectional edges. And there is no
loop. The bad guy starts at 1 node, and other 2 to n node stand di erent girls. Each girl is standing at
di erent nodes, too. The i-th girl has wi. When Hellis meets a girl, he can get jwij point, and he wants
to get max sum of point he gets.(wi < 0 means the i-th girl has phoned him for help).
Input
Multiple test cases. For each test case:
First line, two integers, n ,m (1 < n < 100, 1 < m < 5000)
2th to (m+1)th per line ,ai, bi (0 < ai n, 0 < bi n) means one road from ai to bi.
(m+2)th to (n+m)th per line, wi (0 < jwij 100, 2 i n)
Output
If the guy can meet the girl they chose, output line print a single integer ans )the max sum of point he
gets.
Else print /What is a fucking day!0(without the quotes).
Sample input and output
stdin stdout
3 3
1 2
1 3
2 3
-30
10
30

说实话刚看到这题的时候,这么一大段英文,但时立马就不想看了(虽然英语已经过了六级),但耐下心来仔细阅读,题目意思还是不难理解的,题目的大致意思是,有m条路,找到从点1出发,到达其他路中最大的权值。

#include<stdio.h>
#include<math.h>
#define INF 32767 //起点不是1的定位权值无限大
struct pp
{
 int x;//每条路的起点
 int y;//每条路的终点
 int z;//每条路的魅力值
}p[5000];
int main()
{
    int m,n,i;
    while(scanf("%d%d",&m,&n)!=EOF)
    {
    int j=0,max=0,a[100],flag=1;
    for(i=0;i<m;i++)
    {
    scanf("%d%d",&p[i].x,&p[i].y);
    p[i].z=INF;//初始每条路的魅力值为INF
    }
    for(i=1;i<=n-1;i++)
    {
    scanf("%d",&a[i]);//用数组a接收魅力值
    }
 j=1;
    for(i=0;i<m;i++)
    {
    if(p[i].x==1)
    p[i].z=a[j++];//把数组a中储存的魅力值赋给起点是1的路
    }
    for(i=0;i<m;i++)
    {
    if(p[i].x==1&&abs(p[i].z)>max)
    {
    max=abs(p[i].z);//找出起点是1 的路中,最大的魅力值
    flag=0;
    }
    }
   if(flag)
   printf("What is a fucking day!\n");
   else
   printf("%d\n",max);
}
return 0;
}
   
   
   

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值