hdu 2648 Shopping

hdu 2648 Shopping

Shopping
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1400 Accepted Submission(s): 456

Problem Description
Every girl likes shopping,so does dandelion.Now she finds the shop is increasing the price every day because the Spring Festival is coming .She is fond of a shop which is called “memory”. Now she wants to know the rank of this shop’s price after the change of everyday.

Input
One line contians a number n ( n<=10000),stands for the number of shops.
Then n lines ,each line contains a string (the length is short than 31 and only contains lowercase letters and capital letters.)stands for the name of the shop.
Then a line contians a number m (1<=m<=50),stands for the days .
Then m parts , every parts contians n lines , each line contians a number s and a string p ,stands for this day ,the shop p ‘s price has increased s.

Output
Contains m lines ,In the ith line print a number of the shop “memory” ‘s rank after the ith day. We define the rank as :If there are t shops’ price is higher than the “memory” , than its rank is t+1.

Sample Input
3
memory
kfc
wind
2
49 memory
49 kfc
48 wind
80 kfc
85 wind
83 memory

Sample Output
1
2

Author
dandelion

Source
曾是惊鸿照影来

Recommend
yifenfei

//1218MS    1136K    754 B    C++
//开始还想用排序,后来想想只用容器就够了
//代码好像也写复杂了,id不用另外记录
//在循环中每次循环比较一次就行了 
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
struct node{
    int id;
    int s;
}a[10005];
int main(void)
{
    int n,m,p,id;
    string c;
    map<string,int>M;
    while(cin>>n)
    {
        M.clear();
        for(int i=0;i<n;i++){
            cin>>c;
            M[c]=i;
            if(c=="memory") id=i;
            a[i].s=0;
            a[i].id=i;
        }
        cin>>m;
        while(m--){
            for(int i=0;i<n;i++){
                cin>>p>>c;
                a[M[c]].s+=p;
            }
            int cnt=0;
            for(int i=0;i<n;i++)
                if(a[i].s>a[id].s) cnt++;
            printf("%d\n",cnt+1);
        }
    }
    return 0;
}

 

转载于:https://www.cnblogs.com/GO-NO-1/articles/3333376.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/110011.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • pycharm virtualenv和conda_pycharm文件名红色

    pycharm virtualenv和conda_pycharm文件名红色from: http://www.cnblogs.com/IDRI/p/6354237.htmlLinux:启动虚拟环境:sourceenv/bin/activate Windows:pipinstallvirtualenv创建虚拟环境目录env激活虚拟环境:C:\Python27\Scripts

    2022年8月28日
    3
  • RabbitMQ使用教程(超详细)

    推荐springCloud教程:https://blog.csdn.net/hellozpc/article/details/83692496推荐Springboot2.0教程:https://blog.csdn.net/hellozpc/article/details/82531834文章目录RabbitMQ实战教程1.什么是MQ2.RabbitMQ2.1.RabbitMQ的简介2.2.官…

    2022年4月3日
    46
  • JVM架构和GC垃圾回收机制(JVM面试不用愁)[通俗易懂]

    JVM架构和GC垃圾回收机制(JVM面试不用愁)[通俗易懂]JVM架构和GC垃圾回收机制详解JVM架构图分析下图:参考网络+书籍,如有侵权请见谅(想了解Hadoop内存溢出请看:Hadoop内存溢出(OOM)分类、参数调优化)JVM被分为三个主要的子系统(1)类加载器子系统(2)运行时数据区(3)执行引擎1.类加载器子系统Java的动态类加载功能是由类加载器子系统处理。当它在运行时(不是编译时)首次引用一个类时,它加载、链…

    2022年4月28日
    57
  • 自动化运维平台的流程草图「建议收藏」

    自动化运维平台的流程草图「建议收藏」对于平台里面的几个地方一直没大理清楚,所以想了几种办法,一种是蒙着头继续做,想到哪里做到哪里,结果做的时候发现很多东西都没有规划好,很容易从这个死胡同调入另一个死胡同,所以进度不能保证,质量不能保证。 第二个是…

    2022年5月16日
    45
  • java datagramsocket,Java DatagramSocket和DatagramPacket[通俗易懂]

    java datagramsocket,Java DatagramSocket和DatagramPacket[通俗易懂]JavaDatagramSocket和DatagramPacket1JavaDatagramSocket和DatagramPacketJavaDatagramSocket和DatagramPacket类用于无连接Socket编程。2JavaDatagramSocket类JavaDatagramSocket类表示用于发送和接收数据报包的无连接Socket。DatagramSocket基…

    2022年6月12日
    30
  • cefsharp 执行js_怎么防止js注入

    cefsharp 执行js_怎么防止js注入我试图注入的JavaScript文档的页面后,加载磁头:CefSharpJavaScript注入varbrowserSettings=newBrowserSettings();browserSettings.FileAccessFromFileUrlsAllowed=true;browserSettings.UniversalAccessFromFileUrlsAllowed=t…

    2025年12月3日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号