HRBUST1145-创业

创业
Time Limit: 1000 MSMemory Limit: 65536 K
Total Submit: 586(263 users)Total Accepted: 284(247 users)Rating: Special Judge: No
Description

Leyni是一名IT企业家,他创立了一个搜索引擎公司,用户通过他的搜索引擎进行搜索,他的搜索引擎会根据搜索关键字展现相关的若干条广告,具体的广告展现顺序规则如下:
1.Leyni为每个广告主评价了一个广告质量q
2.每个广告主为自己的广告规定了一个出价bid
3.为了使计费不超过最高出价,Leyni规定cpm = q * bid,并将广告按照cpm从高到低进行排序使得:
q1 * bid1 >= q2 * bid2 >= q3 * bid3 >= ... >= qn * bidn
并按照排序的顺序展现广告。
现在给你N条无序的广告,请你根据如上规则按照展现顺序输出对应的cpm

Input

本题有多组测试数据,对于每组测试数据:
第1行,包含一个数字N,表示有N条广告。(1 <= N <= 10000)
第2..N + 1行,每行一对整数,分别对应广告的q,bid。(1 <= q, bid <= 1000)

Output

对于每组测试数据:
第1行,输出排序后的N个cpm值,数字间用一个空格进行分割。

Sample Input
3
3 2
1 1
2 1
Sample Output
6 2 1
Author
齐达拉图


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <stack>
#include <map>
#include <climits>
#include <functional>

using namespace std;

#define LL long long
const int INF=0x3f3f3f3f;

int a[10009],b[10009],c[10009];

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=n;i++)
        {
            scanf("%d %d",&a[i],&b[i]);
            c[i]=a[i]*b[i];
        }
        sort(c+1,c+1+n);
        printf("%d",c[n]);
        for(int i=n-1;i>=1;i--)
            printf(" %d",c[i]);
        printf("\n");
    }
    return 0;
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值