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)
上一篇 2021年8月26日 上午7:00
下一篇 2021年8月26日 上午8:00


相关推荐

  • java notifyall_notify的用法

    java notifyall_notify的用法作者:知乎用户链接:https://www.zhihu.com/question/37601861/answer/145545371来源:知乎著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。今天正好碰到这个问题,也疑惑了好久。看了一圈知乎上的答案,感觉没说到根上。所以自己又好好Google了一下,终于找到了让自己信服的解释。先说两个概念:锁池和等待池锁池:假设线程A已经拥有了某…

    2025年10月9日
    5
  • A2W W2A A2T T2A _T() 含义以及用法

    A2W W2A A2T T2A _T() 含义以及用法A2W、W2A、A2T、T2A _T() 的含义及使用方法1、A2W和W2A在《Window核心编程》,多字节和宽字节之间转换比较麻烦的,MultiByteToWideChar函数和WideCharToMultiByte函数有足够多的参数的意义让我们去理解。那么使用ATL的一个很好的字符串的转换宏:A2W和W2A。char:8位字节类型,表示ASCII码WCHAR:16位字符类型,表示Un…

    2022年8月18日
    7
  • getAttribute()获取属性

    getAttribute()获取属性一份文档就是一棵节点树 节点分为不同的类型 元素节点 属性节点和文本节点等 getElementBy 方法将返回一个对象 该对象对应着文档里的一个特定的元素节点 getElementsB 方法将返回一个对象数组 它们分别对应着文档里的一个特定的元素节点 这些节点中的每个都是一个对象 接下来 我们将向大家介绍几个与这些对象相关联的属性和方法 3

    2026年3月18日
    2
  • 最详细的maven配置——报错了你打我[通俗易懂]

    最详细的maven配置——报错了你打我[通俗易懂]目录1、前言2、下载3、配置PATH、settings.xml以及本地仓库3.1、配置path3.2、配置settings.xml和本地仓库4、在IDEA中配置Maven1、前言maven说的简短一点就是一个大型的jar包管理工具,类似于工具人。只要有了maven,就不用去幸幸苦苦的找jar包了。wc,爽哉。好了,还是不多bb,我么还是直接干正事。(切记切记:安装maven必须装好jdk)2、下载首先我们还是去官网。瞅瞅最新版的是哪个版本。点我直达当然,玩Windows的人都知道,我们下

    2022年5月28日
    54
  • 腾讯元宝手机版

    腾讯元宝手机版

    2026年3月13日
    2
  • ELK搭建 – Docker篇

    ELK搭建 – Docker篇ELK 分布式日志搜集分析系统 ELK 分布式日志收集系统介绍那么 ELK 到底是什么呢 ELK 是三个开源项目的首字母缩写 这三个项目分别是 Elasticsearc Logstash 和 Kibana Elasticsearc 是一个搜索和分析引擎 Logstash 是服务器端数据处理管道 能够同时从多个来源采集数据 转换数据 然后将数据发送到诸如 Elasticsearc 等 存储库 中 Kibana 则可以让用户在 Elasticsearc 中使用图形和图表对数据进行可视化 引用官网

    2026年3月26日
    2

发表回复

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

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