zoukankan      html  css  js  c++  java
  • HDU 6015 Skip the Class

    Skip the Class

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
    Total Submission(s): 401    Accepted Submission(s): 235


    Problem Description
    Finally term begins. luras loves school so much as she could skip the class happily again.(wtf?)

    Luras will take n lessons in sequence(in another word, to have a chance to skip xDDDD).

    For every lesson, it has its own type and value to skip.

    But the only thing to note here is that luras can't skip the same type lesson more than twice.

    Which means if she have escaped the class type twice, she has to take all other lessons of this type.

    Now please answer the highest value luras can earn if she choose in the best way.
     

    Input
    The first line is an integer T which indicates the case number.

    And as for each case, the first line is an integer n which indicates the number of lessons luras will take in sequence.

    Then there are n lines, for each line, there is a string consists of letters from 'a' to 'z' which is within the length of 10,
    and there is also an integer which is the value of this lesson.

    The string indicates the lesson type and the same string stands for the same lesson type.

    It is guaranteed that——

    T is about 1000

    For 100% cases, 1 <= n <= 100,1 <= |s| <= 10, 1 <= v <= 1000
     

    Output
    As for each case, you need to output a single line.
    there should be 1 integer in the line which represents the highest value luras can earn if she choose in the best way.
     

    Sample Input
    2 5 english 1 english 2 english 3 math 10 cook 100 2 a 1 a 2
     

    Sample Output
    115 3
    水题:
    #include <iostream>
    #include <string.h>
    #include <stdlib.h>
    #include <algorithm>
    #include <math.h>
    #include <stdio.h>
    #include <map>
    #include <string>
    #include <vector>
    
    using namespace std;
    map<string,int> m;
    string s;
    int value;
    int n;
    vector<int> v[105];
    int main()
    {
        int t;
        scanf("%d",&t);
        int ans=0;
        while(t--)
        {
            scanf("%d",&n);
            int cot=0;
            ans=0;
            m.clear();
            for(int i=1;i<=n;i++)
                v[i].clear();
            for(int i=1;i<=n;i++)
            {
                cin>>s>>value;
                if(!m[s]) m[s]=++cot;
                v[m[s]].push_back(value);
            }
            for(int i=1;i<=cot;i++)
                sort(v[i].begin(),v[i].end());
            for(int i=1;i<=cot;i++)
            {
                int l=v[i].size()-1;
                ans+=v[i][l];
                if(l>=1)
                ans+=v[i][l-1];
            }
            printf("%d
    ",ans);
        }
        return 0;
    }



     
  • 相关阅读:
    燃尽的一个不便之处修改
    jquery给元素添加样式表的方法
    http协议
    春节读书
    file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known
    jQuery on(),live(),trigger()
    jquery ui中的dialog,官网上经典的例子
    问题:循环元素,被选中元素个数,全选
    3.5星|《小学问》:年轻人思维与婚恋常见误区解析
    正念疗法入门介绍,作者是日籍美国正念疗法医生:3星|《高效休息法》
  • 原文地址:https://www.cnblogs.com/dacc123/p/8228557.html
Copyright © 2011-2022 走看看