bestcoder 92
来源:互联网 发布:js 去重 filter书数组 编辑:程序博客网 时间:2024/04/28 01:42
hdu 6015
sort之后每个相同的字符串加最大的两个到ans上
hdu 6016
枚举每一个中间的边
因为一条符合要求的链要三条边
所以每一条中间的边的两个端点的度减去一再乘
就是以这一条边为中间的边的链数了
也没有重复的问题
hdu 6015
#include<bits/stdc++.h>
using namespace std;
typedef pair<string,int> l;
pair<string,int>lesson[1010];
bool cmp(const l &a, const l &b)
{
if (a.first < b.first)
return true;
else if(a.first==b.first)
{
if(a.second>b.second)
return true;
else return false;
}
else return false;
}
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>lesson[i].first>>lesson[i].second;
}
sort(lesson,lesson+n,cmp);
int ans=0;
int judge=0;
for(int i=0;i<n;i++)
{
if(i==0)
{
ans+=lesson[i].second;judge++;
}
else
{
if(lesson[i].first==lesson[i-1].first)
{
if(judge<2)
{
ans+=lesson[i].second;
judge++;
}
else continue;
}
else
{
judge=1;
ans+=lesson[i].second;
}
}
}
cout<<ans<<endl;
}
return 0;
}
hdu 6016
- bestcoder 92
- bestcoder 92
- BestCoder
- bestcoder
- BestCoder Round #92 第一次BC
- BestCoder Round #92 题解 (待续)
- BestCoder Round #92 A+B
- BestCoder Round #92 1001 hdu6015
- BestCoder Round #92【map,枚举,DP】
- Bestcoder#92Girls Love 233(dp)
- HDU 6015 bestcoder #92 Skip the Class
- BestCoder Round #92-1002 Count the Sheep
- BestCoder Round #92-1003 Girls Love 233
- BestCoder Round#92 1002 Count the Sheep
- bestcoder #92 B Count the Sheep(思维)
- BestCoder Round #92 1001 Skip the Class【HDU6015】【STL】
- BestCoder Round #92 1002 Count the Sheep(思维)【HDU6016】
- BestCoder Round #92A Skip the Class(map)
- java之重要知识
- Linux档案与目录管理
- LVM-逻辑卷
- LeetCode 461 Hamming Distance
- 第七届蓝桥杯省赛Java语言C组_搭积木
- bestcoder 92
- 云计算Openstack-Liberty版-Cinder+lbaas -学习笔记
- 玻尔兹曼机的描述
- C++-多态性
- BP(反向传播)算法和CNN反向传播算法推导(转载)
- JSP之静态include指令、动态Include指令
- PAT甲级1008. Elevator (20)
- 层次算法聚类(四)
- Python Tutorial one