CCC2024青少年组真题+解析(上)

Problem J1: Conveyor Belt Sushi

Problem Description

There is a new conveyor belt sushi restaurant in town. Plates of sushi travel around the restaurant on a raised conveyor belt and customers choose what to eat by removing plates. Each red plate of sushi costs $3, each green plate of sushi costs $4, and each blue plate of sushi costs $5.

Your job is to determine the cost of a meal, given the number of plates of each colour chosen by a customer.

Input Specification

The first line of input contains a non-negative integer, R, representing the number of red plates chosen. The second line contains a non-negative integer, G, representing the number of green plates chosen. The third line contains a non-negative integer, B, representing the number of blue plates chosen.

Output Specification

Output the non-negative integer, C, which is the cost of the meal in dollars.

Sample Input

0 2 4

Output for Sample Input

28

Explanation of Output for Sample Input

This customer chose 0 red plates, 2 green plates, and 4 blue plates. Therefore, the cost of the meal in dollars is 0 × 3+2 × 4+4 × 5 = 28

贴心的翻译

问题描述

城里有一家新的传送带寿司店。一盘盘寿司在一条凸起的传送带上在餐厅里走来走去,顾客通过取下盘子来选择吃什么。每盘红色的寿司要3美元,每盘绿色的寿司要4美元,而每盘蓝色的寿司要5美元。
你的工作是根据顾客选择的每种颜色的盘子数量来确定一顿饭的成本。

输入规范

第一行输入包含一个非负整数R,表示所选红板的数量。第二行包含一个非负整数G,表示所选绿色板的数量。第三行包含一个非负整数B,表示所选蓝色板的数量。

输出规格

输出非负整数C,这是以美元为单位的膳食成本。

样本输入

0 2 4

样本输入的输出

28

示例输入的输出说明

该客户选择了0个红色板、2个绿色板和4个蓝色板,共计28美元

解析:

这道题是非常非常简单的,按照题目的规则计算就可以了。

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

int main(){
    int r,g,b;
    cin>>r>>g>>b;
    cout<<3*r+4*g+5*b;
    return 0;
}

Problem J2: Dusa And The Yobis

Problem Description

Dusa eats Yobis, but only Yobis of a certain size. If Dusa encounters a Yobi that is smaller than itself, it eats the Yobi, and absorbs its size. For example, if Dusa is of size 10 and it encounters a Yobi of size 6, Dusa eats the Yobi and expands to size 10 + 6 = 16. If Dusa encounters a Yobi that is the same size as itself or larger, Dusa runs away without eating the Yobi. Dusa is currently facing a line of Yobis and will encounter them in order. Dusa is guaranteed to eventually encounter a Yobi that causes it to run away. Your job is to determine Dusa’s size when this happens.

Input Specification

The first line of input contains a positive integer, D, representing Dusa’s starting size. The remaining lines of input contain positive integers representing the sizes of the Yobis in order.

Output Specification

Output the positive integer, R, which is Dusa’s size when it eventually runs away.

Sample Input 1

5 3 2 9 20 22 14

Output for Sample Input 1

19

Explanation of Output for Sample Input 1

Dusa is large enough to eat the Yobi of size 3. This brings Dusa’s size to 8. Dusa is large enough to eat the Yobi of size 2. This brings Dusa’s size to 10. Dusa is large enough to eat the Yobi of size 9. This brings Dusa’s size to 19. The Yobi of size 20 causes Dusa to run away. Sample Input 2 10 10 3 5 13 Output for Sample Input 2 10 Explanation of Output for Sample Input 2 The Yobi of size 10 causes Dusa to run away, leaving its size unchanged.

贴心的翻译

问题描述

Dusa吃Yobis,但只吃一定大小的Yobis。如果Dusa遇到比自己小的Yobi,它会吃掉Yobi,并吸收它的大小。例如,如果Dusa是10号,并且遇到了6号的Yobi,则Dusa吃掉Yobi并扩展到10+6=16号。如果Dusa遇到一只与自己大小相同或更大的Yobi,Dusa会在没有吃掉Yobi的情况下逃跑。Dusa目前正面临一排Yobi,并将按顺序遇到它们。Dusa最终肯定会遇到一只尤比,导致它逃跑。当这种情况发生时,你的工作就是确定Dusa的大小。

输入规范

第一行输入包含一个正整数D,表示Dusa的起始大小。其余的输入行包含正整数,按顺序表示Yobis的大小。

输出规格

输出正整数R,这是Dusa最终逃跑时的大小。

样本输入1

5 3 2 9 20 22 14

样本输入1的输出

19

示例输入1的输出说明

Dusa足够大,可以吃3号的尤比。这使Dusa的尺码达到8码。Dusa足够大,可以吃2号的Yobi。这使Dusa的尺码达到10码。Dusa足够大,可以吃9号的Yobi。这使Dusa的尺码达到19码。20号的Yobi让Dusa逃跑了。

解析:

这道题同样很简单啊,也是按照题目的要求来就可以了。

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

int main(){
    int r,d;
    cin>>r;
    while(cin>>d){
        if (r<=d){
            cout<<r;
            return 0;
        }else r+=d;
    }
    return 0;
}

Problem J3: Bronze Count

Problem Description

After completing a competition, you are struck with curiosity. How many participants were awarded bronze level? Gold level is awarded to all participants who achieve the highest score. Silver level is awarded to all participants who achieve the second highest score. Bronze level is awarded to all participants who achieve the third highest score. Given a list of all the scores, your job is to determine the score required for bronze level and how many participants achieved this score.

Input Specification

The first line of input contains a positive integer, N, representing the number of participants. Each of the next N lines of input contain a single integer representing a participant’s score. Each score is between 0 and 75 (inclusive) and there will be at least three distinct scores.

The following table shows how the available 15 marks are distributed:

40%marks N≤50;85%marks N≤500;100% N≤250000;

Output Specification

Output a non-negative integer, S, and a positive integer, P, separated by a single space, where S is the score required for bronze level and P is how many participants achieved this score. La version fran¸caise figure `a la suite de la version anglaise.

Sample Input 1

4 70 62 58 73

Output for Sample Input 1

62 1

Explanation of Output for Sample Input 1

The score required for bronze level is 62 and one participant achieved this score.

Sample Input 2

8 75 70 60 70 70 60 75 70

Output for Sample Input 2

60 2

Explanation of Output for Sample Input 2

The score required for bronze level is 60 and two participants achieved this score.

贴心的翻译 

题目描述

完成比赛后,你会被好奇心所打动。有多少参与者获得铜牌?金牌级别授予所有获得最高分数的参与者。银牌级别授予所有获得第二高分的参与者。铜牌级别授予所有获得第三高分的参与者。给出所有分数的列表,你的工作是确定铜牌级别所需的分数,以及有多少参与者达到了这个分数。


输入规范

第一行输入包含一个正整数N,表示参与者的数量。接下来的N行输入中的每一行都包含一个表示参与者分数的整数。每个分数在0到75之间(包括0和75),并且至少有三个不同的分数。

下表显示了可用的15个标记的分布方式:
40%标记N≤50;85%标记N≤500 ;100%N≤250000

输出规格

输出一个非负整数S和一个正整数P,用一个空格分隔,其中S是铜牌级别所需的分数,P是获得该分数的参与者人数。

样本输入1

4
70 62 58 73

样本输入1的输出

62 1

示例输入1的输出说明

铜牌级别所需的分数是62分,一名参与者获得了这一分数。

样本输入2

8
75 70 60 70 70 60 75 70

样本输入2的输出

60 2

示例输入2的输出说明

铜牌级别要求的分数是60分,两名参与者获得了这一分数。 

解析:

这道题就是进行排序,然后看第三高的分数有多少人刚好达到,也就是等于这个分数,这里可以运用桶排序。

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

int a[250100],maxn=-1,cnt[80],sum=1;

bool cmp(int q,int w){
    return q>w;
}
int main(){
    int n;
    cin>>n;
    for (int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n,cmp);//这里先排一下,方便找最大值,从而减少运行次序
    maxn=a[0];
    for (int i=0;i<n;i++){//桶排序
        cnt[a[i]]++;
    }
    for (int i=maxn;i>=0;i--){
        if (cnt[i]!=0&&sum==3){
            cout<<i<<" "<<cnt[i];
            break;
        }else if (cnt[i]!=0)sum++;
    }
    return 0;
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值