hdu 3744 A Runing Game

10000米赛跑排名判断
本文介绍了一道编程题,题目要求根据运动员在赛道上的位置和给出的排名列表来判断该排名是否合理。通过算法分析,文章提供了一个解决方案,并详细解释了其工作原理。

## A Runing Game ##
A Runing Game

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 917 Accepted Submission(s): 412

Problem Description
HDU hosts sporting meeting every year. One of the most exciting events is the 10000M-running.During the match many students are running on the track. So, how about the rank list now?

As we know, in a running , we rank the player according to the length everyone has passed . So if one player run 400M(one lap) farther than another player , it looks like they are running at the same position on the track , but the rank of the former is much better than the latter. Now given everyone’s position on the track , and one rank list , can you tell me whether the rank list is possible.

Input
The first line of input gives the number of cases, T (at most 110). the first line of each case has two intergers, n,m. (1 <= n <= 100,1 <= m <= 40000,n <= m),represents there’re n players in the m-meter running.
then n lines describe every player.

Each line have two intergers , Xi , Ri .Representing the i-th player is running at xi[0 , 399] meter in his recent lap, and ranks Ri in the ranklist .And the data make sure that no pair of the students have the same Xi or Ri. And the start point is at 0 in their first lap.

Output
If the rank list is possible, output “YES” ,output “NO” otherwise.

Sample Input
2
3 400
100 1
49 2
28 3
3 800
100 1
150 2
154 3

Sample Output
YES
NO

题目大意:T组数据,每组数据有参赛人数n和要跑多少米m的长度,然后n行两个数据a,b。a代表这个人距离起点的位置,b代表这个人的名次,问你这个名次有没有可能。

想法:创建一个数组,用下标表示名次,这样就可以省去排序的时间。如果前一名的位置在后一名的位置的前面,如果要排名是成立的,那么两个人可以在同一圈,就把这个人的位置加上他跑的最大圈数。如果前一名的位置在后一名的位置的后面,如果要排名成立,那么前一名一定要比后一名多跑一圈。所以前一名的跑步长度要比后一名的跑步长度多一圈,最后判断是不是所有的前一名跑步的长度都要比后一名的要长。

#include<bits/stdc++.h>
using namespace std;
int a[101];
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        memset(a,0,sizeof(a));
        int n,m;
        cin>>n>>m;
        int x,y;
        for(int i=0;i<n;i++)
        {
            cin>>x>>y;
            a[y]=x;
        }
        int q=m/400,r=m%400;
        if(a[1]<=r)
        {
            a[1]=a[1]+q*400;
        }
        else
        {
            a[1]=a[1]+(q-1)*400;
            q--;
        }
        for(int i=2;i<=n;i++)
        {
            if((a[i]+q*400)<a[i-1])
            {
            //    q--;
                if(q<0)
                q=0;
                a[i]=a[i]+q*400;

            }
            else
            {
                q--;
                if(q<=0)
                q=0;
                a[i]=a[i]+q*400;
            }
        }
        int flag=0;
        for(int i=2;i<=n;i++)
        {
            if(a[i-1]>a[i])
            continue;
            else
            {
                cout<<"NO"<<endl;
                flag=1;
                break;
            }
        }
        if(flag==0)
        cout<<"YES"<<endl;
    }
    return 0;
}

代码提交地址:http://acm.hdu.edu.cn/showproblem.php?pid=3744

内容概要:本文介绍了一个基于Matlab的综合能源系统优化调度仿真资源,重点实现了含光热电站、有机朗肯循环(ORC)和电含光热电站、有机有机朗肯循环、P2G的综合能源优化调度(Matlab代码实现)转气(P2G)技术的冷、热、电多能互补系统的优化调度模型。该模型充分考虑多种能源形式的协同转换与利用,通过Matlab代码构建系统架构、设定约束条件并求解优化目标,旨在提升综合能源系统的运行效率与经济性,同时兼顾灵活性供需不确定性下的储能优化配置问题。文中还提到了相关仿真技术支持,如YALMIP工具包的应用,适用于复杂能源系统的建模与求解。; 适合人群:具备一定Matlab编程基础和能源系统背景知识的科研人员、研究生及工程技术人员,尤其适合从事综合能源系统、可再生能源利用、电力系统优化等方向的研究者。; 使用场景及目标:①研究含光热、ORC和P2G的多能系统协调调度机制;②开展考虑不确定性的储能优化配置与经济调度仿真;③学习Matlab在能源系统优化中的建模与求解方法,复现高水平论文(如EI期刊)中的算法案例。; 阅读建议:建议读者结合文档提供的网盘资源,下载完整代码和案例文件,按照目录顺序逐步学习,重点关注模型构建逻辑、约束设置与求解器调用方式,并通过修改参数进行仿真实验,加深对综合能源系统优化调度的理解。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值