zoukankan      html  css  js  c++  java
  • PAT Basic 1092 最好吃的月饼 (20 分)

    月饼是久负盛名的中国传统糕点之一,自唐朝以来,已经发展出几百品种。

    mk.jpg

    若想评比出一种“最好吃”的月饼,那势必在吃货界引发一场腥风血雨…… 在这里我们用数字说话,给出全国各地各种月饼的销量,要求你从中找出销量冠军,认定为最好吃的月饼。

    输入格式:

    输入首先给出两个正整数 N(≤)和 M(≤),分别为月饼的种类数(于是默认月饼种类从 1 到 N 编号)和参与统计的城市数量。

    接下来 M 行,每行给出 N 个非负整数(均不超过 1 百万),其中第 i 个整数为第 i 种月饼的销量(块)。数字间以空格分隔。

    输出格式:

    在第一行中输出最大销量,第二行输出销量最大的月饼的种类编号。如果冠军不唯一,则按编号递增顺序输出并列冠军。数字间以 1 个空格分隔,行首尾不得有多余空格。

    输入样例:

    5 3
    1001 992 0 233 6
    8 0 2018 0 2008
    36 18 0 1024 4
    

    输出样例:

    2018
    3 5


    #include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;
    int main(){
        int row,column,tmp;
        vector<int> vec;
        cin>>column>>row;
        int val[column];
        fill(val,val+column,0);
        for(int i=0;i<row;i++)
            for(int j=0;j<column;j++){
                cin>>tmp;
                val[j]+=tmp;
            }
        int max_value=-1,coun=0;
        for(int i=0;i<column;i++)
            if(val[i]>max_value)
                max_value=val[i];
        cout<<max_value<<endl;
        for(int i=0;i<column;i++)
            if(val[i]==max_value)
                vec.push_back(i);
        for(int i=0;i<vec.size();i++)
            if(i!=vec.size()-1)cout<<vec[i]+1<<" ";
            else cout<<vec[i]+1;
        system("pause");
        return 0;
    }
  • 相关阅读:
    Spring Boot启用Swagger2
    Springboot 注解最全详解
    spring-boot-starter-data-jpa 解析
    springboot 微信支付
    springboot整合PageHelper
    SpringBoot配置HTTPS,并实现HTTP访问自动转HTTPS访问
    Springboot 发送短信验证码
    Java volatile关键字的作用
    Android兼容性测试应该怎么做逼格更高呢?
    hadoop日志【2】
  • 原文地址:https://www.cnblogs.com/littlepage/p/11593486.html
Copyright © 2011-2022 走看看