码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 6015 Skip the Class

时间:2017-08-06 19:36:44      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:sof   sync   ace   mil   c++   ++   color   line   ret   

Skip the Class

代码:

 

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ls rt<<1,l,m
#define rs rt<<1|1,m+1,r
#define pb push_back
#define mem(a,b) memset((a),(b),sizeof(a))
const int INF=0x3f3f3f3f;
const int N=105;
struct lesson
{
    string s;
    int v;
    operator < (const lesson &t) const
    {
        return v>t.v;
    }
}a[N];
map<string,int>mp;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
        mp.clear();
        int n;
        cin>>n;
        for(int i=0;i<n;i++)cin>>a[i].s>>a[i].v;
        sort(a,a+n);
        int ans=0;
        for(int i=0;i<n;i++)
        {
            if(mp[a[i].s]<2)
            {
                ans+=a[i].v;
                mp[a[i].s]++;
            }
        }
        cout<<ans<<endl;
    } 
    return 0;
}

 

HDU 6015 Skip the Class

标签:sof   sync   ace   mil   c++   ++   color   line   ret   

原文地址:http://www.cnblogs.com/widsom/p/7295528.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!