POJ 1922 Ride to School#贪心

(~ ̄▽ ̄)~*

//C跟着a君骑,然后更快的b君来了,C又跟着b君骑,
//接着最快的d君来了,C就去跟着d君了,
//最后最快的d君到达目的地时,C也就到了
//所以C的到达时间,就是最早到达的那个人的到达时间
//tips:但是,ti为负数者,速度又快的话,那C是永远追不上的
//所以结果应该是ti为正,即在C后才出发,的最快者所用时
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)&&n)
    {
        int v,t;
        int res=10e8;
        while(n--)
        {
            scanf("%d%d",&v,&t);
            if(t>=0)//注意要>=0,如果是>0会WA,因为有可能C就是最快的那个
            {
                int T=ceil(4.5*3600/v+t);//比int T=(int)ceil(16200.0/v)+t;要快..好像也差不多 感觉要看看oj的心情
                res=min(res,T);
            }
        }
        printf("%d\n",res);
    }
    return 0;
}
时间: 2024-08-05 19:35:19

POJ 1922 Ride to School#贪心的相关文章

贪心/poj 1922 Ride to School

1 #include<cstdio> 2 #include<cmath> 3 using namespace std; 4 int n,ans,v,t; 5 int main() 6 { 7 scanf("%d",&n); 8 while (n!=0) 9 { 10 ans=0x7fffffff; 11 for (int i=1;i<=n;i++) 12 { 13 scanf("%d%d",&v,&t); 14

POJ 1922 Ride to School

Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 19986   Accepted: 8058 Description Many graduate students of Peking University are living in Wanliu Campus, which is 4.5 kilometers from the main campus – Yanyuan. Students in Wanliu have t

POJ 2965-The Pilots Brothers&#39; refrigerator(贪心+枚举)

The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19464   Accepted: 7462   Special Judge Description The game "The Pilots Brothers: following the stripy elephant" has a quest where a player needs to o

poj 2586 Y2K Accounting Bug (贪心)

Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9632   Accepted: 4806 Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for preparing annual report for MS Inc.

POJ 1328、Radar Installation 贪心

jQuery的属性操作非常简单,下面以一个a元素来说明属性的获取/设置/删除操作 <body> <a>jquery.com</a> </body> 添加属性 $('a').attr('href', 'http://www.jquery.com') 添加多个属性 $('a').attr({'href':'http://www.jquery.com', 'title':'jquery.com'}) 获取属性 $('a').attr('href') class属性

POJ 3069 Saruman&#39;s Army(贪心)

Saruman's Army Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 3069 Appoint description:  System Crawler  (2015-04-27) Description Saruman the White must lead his army along a straight path from

poj 2393 Yogurt Factory(贪心)

Description The cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over the next N (1 <= N <= 10,000) weeks, the price of milk and labor will fluctuate weekly such that it will cost the company C_i (1 <= C_i <= 5,000) c

POJ 2393 Yogurt factory(简单贪心)

http://poj.org/problem?id=2393 题意:任务规定,一个酸奶制造厂,在n个星期内,分别要向外提供y[i]unit的酸奶.已知这个制造厂第i周制造每unit酸奶的费用为c[i],储存室储存每1unit酸奶1星期的费用为s.问要完成这个任务的最小费用是多少. . . . . . . . . . . . . . 思路:简单贪心.维护一个目前最优的代价minc = min(c, minc + s),然后求和. #include <iostream> using namespa

poj 1065 Wooden Sticks 【贪心 新思维】

题目地址:http://poj.org/problem?id=1065 Sample Input 3 5 4 9 5 2 2 1 3 5 1 4 3 2 2 1 1 2 2 3 1 3 2 2 3 1 Sample Output 2 1 3 题目抽象:给你一个序列,序列的每个元素包含两个值(x,y).现在希望找到最少数目的条件序列.条件序列是这样的:cur.x<=(cur+1).x && cur.y<=(cur+1).y满足条件的序列的最少的数目是多少?代码: 1 #inclu