HubeiCPC2023 M - Different Billing

M. Different Billing

Once upon a time, there was an onsite programming contest, which had attracted many teams to participate in. However, different teams had a different billing standard. In general, there were three types of teams:

  • Teams of Type A could participate in the contest for free.
  • Teams of Type B had to pay 1000 dollars for the expenses for board and lodging.
  • Teams of Type C had to pay 1000 dollars for the expenses for board and lodging and 1500 dollars for entry fee.

Finally the contest was held successfully with x x x teams in total participating in, and the host had earned y y y dollars. However, the details about the number of teams of each type had vanished. Now Walk Alone wants to restore the details using x x x and y y y.
Input
The only line of input contains two integers x x x and y ( 0 ≤ x ≤ 1 0 6 , 0 ≤ y ≤ 1 0 9 ) y (0≤x≤10^6, 0≤y≤10^9) y(0x106,0y109), denoting the number of teams in total and the total amount of money the host had earned.
Output
If there’s a way to construct the number three types of teams satisfying the condition above, output three integers A , B , C A,B,C A,B,C to denote the number of teams of type A, B and C. You need to guarantee that 0 ≤ A , B , C 0≤A,B,C 0A,B,C. If there are multiple ways, output any of them.
If there’s no answer satisfying the condition above, output −1 instead.
Examples
input

800 1500000

output

200 0 600

input

0 0

output

0 0 0

input

500 100

output

-1

Note
For the first sample test case you can also output 50 50 50 250 250 250 500 500 500, which can also satisfy the condition above.
For the second sample test case, there’s nobody who needs to bill participating in the contest, so no money can be earned by the host.
For the third sample test case, the host cannot earn such little money. So output −1.

题目大意:
给定总队伍数 x x x ( a + b + c ) (a+b+c) (a+b+c) 和主办方收到的金钱数 y y y,如何分配3种队伍 a , b , c a, b, c a,b,c 的数量,恰好使得总金钱数为 y y y
解题思路:
其实就是尽量把 y y y 分完。特别的是要知道可以把已经分给 C 的拿出来加上 B 分剩下的还能不能再分完(啥也不剩的那种)若能恰好分完,则输出对应队伍数的分配;若不能,则输出 − 1 -1 1
(虽然还有些情况没考虑上,但是能过 😃 )

#include <bits/stdc++.h>
using namespace std;

const int costB = 1000, costC = 2500;

int main()
{
    int x, y; cin>>x>>y;
    int c = y/costC;
    y %= costC;
    int b = y/costB;
    if(y%costB) //看队伍B有无剩余(或者队伍C有没有选完)
    {
        if(y%costB==500 && c) //有剩余就看能不能把队伍C拆一个过来
        {
            c--, b += 3; //500+2500
            cout<<x-b-c<<' '<<b<<' '<<c;
        }
        else cout<<-1;
    }
    else cout<<x-b-c<<' '<<b<<' '<<c;
    return 0;
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

花生ono

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值