HDU 3233 Download Manager(模拟)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3233

题意:有很多文件要下,但是宽带总量是有限的,只能同时下一部分。下载顺序:先下载较小的文件,如果文件大小相同,先下剩余未下载部分较小的。求下载所需时间。一开始按照题目描述分情况写,结果TLE了,看了看其他人提交的几乎都是错过一次就A了,后来想了想不管下什么,每时刻宽带流量是一定的,每时刻时间又一定,所以每时刻下载的文件量是一定的,不管分不分情况都一样,所以就直接求的,然后按照这个想法写好交了一次就A了。

#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
using namespace std ;
typedef long long ll;
const double inf = 0x3f3f3f3f3f3f3f;
const int maxn = 25000;
int vis[maxn];
struct file
{
    double total, rest, have_down;
    file(){};
    file(double total,double rest,double have_down) {};
    bool operator<(const file &f) const
    {
        if(total != f.total) return total < f.total;
        return rest < f.rest;
    }
}f[maxn];
int main()
{
    int t,n,b;
    int kase = 0;
    while(~scanf("%d%d%d",&t,&n,&b))
    {
        if(!n && !t && !b) break;
        double sum = 0.0;
        for(int i = 0; i < t; i++)
        {
            scanf("%lf%lf",&f[i].total, &f[i].have_down);
            if(f[i].have_down < 100.0)
                f[i].rest = f[i].total * (1.0 - f[i].have_down * 0.01);
            else
                f[i].rest = 0;
            sum += f[i].rest;
        }
        printf("Case %d: %.2lf\n\n",++kase, sum / b);
    }
    return 0;
}



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值