URAL 1728. Curse on Team.GOV(STL set)
题目链接: space=1&num=1728" target="_blank">http://acm.timus.ru/problem.aspx?space=1&num=1728
1728. Curse on Team.GOV
Memory limit: 64 MB
in contests for a whole year. But once, after a conflict at a contest in Kazan, Lyosha and Vadik expelled Misha from the team and changed its name to Team.GOV.
in that contest without the third programmer. However, Sasha was not expelled from the team and took part in a subregional contest, which they lost. After that, the team “Lyosha, Vadik, Sasha” suddenly turned into the team “Vanya, Lyosha, Vadik” and went to
the regional contest, which they also lost.
the rating of each candidate according to a secret formula. The power of the team is equal to the sum of the ratings of its members. Lyosha and Vadik want their team to be as powerful as possible. But the team is cursed… As the fates decree, if the team composition
repeats a composition that once participated in some contest, Lyosha won't be able to come to the contest (and the power of the team will decrease by his rating). Even in this case, if this team composition (without Lyosha) participated in some contest earlier,
Team.GOV will suddenly be disqualified during the practice session and won't take part in the contest. Help the permanent members of Team.GOV choose the third member so that the team will be as powerful as possible in the subregional contest.
Input
of the team's members that participated in the contest (an integer in the range from one to three). This number is followed by the space-separated list of last names of these members given in the alphabetical order. The names are different nonempty strings
consisting of lowercase and uppercase English letters. The length of each name is at most 50. Lyosha's last name is Efremov and Vadik's last name is Kantorov. It is guaranteed that Vadik is present in all the compositions, and Lyosha is present in all the
compositions consisting of three people. All the given compositions are different.
≤ re, rk ≤ 666). They are Lyosha's and Vadik's ratings, respectively. The
following line contains the number m of candidates who want to enter the team (1 ≤ m ≤ 100). Each of the following m lines contains the last name and the rating of a candidate separated with a space. All the ratings are integers
in the range from 1 to 666. All the last names are different. The list of candidates contains neither Lyosha nor Vadik.
Output
who will become the third member of Team.GOV. If there are several possible answers, output any of them.
Samples
input | output |
---|---|
6 |
Win |
2 |
Fail |
代码例如以下:
#include <cstdio>
#include <cstring>
#include <string>
#include <set>
#include <iostream>
#include <algorithm>
using namespace std;
set<string>m2, m3;
int main()
{
int n, m;
string s;
while(~scanf("%d",&n))
{
for(int i = 0; i < n; i++)
{
cin >> m;
for(int j = 0; j < m; j++)
{
cin >> s;
if(s != "Kantorov" && s != "Efremov")
{
if(m == 2)
{
m2.insert(s);
}
else if(m == 3)
{
m3.insert(s);
}
}
}
}
int pe, pk;
int q, power;
string qq;
cin >> pe >> pk;
cin >> q;
string ans;
int maxx = 0;
for(int i = 0; i < q; i++)
{
cin >> qq >> power;
if(m2.count(qq)==0 && pk+power > maxx)
{
ans = qq;
maxx = pk+power;
}
if(m3.count(qq)==0 && pk+power+pe > maxx)
{
ans = qq;
maxx = pk+power+pe;
}
}
if(maxx == 0)
{
cout<<"Fail"<<endl;
}
else
{
cout<<"Win"<<endl;
cout<<ans<<endl;
}
}
return 0;
}
URAL 1728. Curse on Team.GOV(STL set)的更多相关文章
- random_shuffle (stl算法)打乱顺序 - 飞不会的日志 - 网易博客
random_shuffle (stl算法)打乱顺序 - 飞不会的日志 - 网易博客 random_shuffle (stl算法)打乱顺序 2012-03-31 10:39:11| 分类: 算法 | ...
- P1540 机器翻译(STL 链表)
题目背景 小晨的电脑上安装了一个机器翻译软件,他经常用这个软件来翻译英语文章. 题目描述 这个翻译软件的原理很简单,它只是从头到尾,依次将每个英文单词用对应的中文含义来替换.对于每个英文单词,软件会先 ...
- 【UVA - 540】Team Queue (map,队列)
Team Queue Descriptions: Queues and Priority Queues are data structures which are known to most comp ...
- 堆模板(STL版)
题目描述 如题,初始小根堆为空,我们需要支持以下3种操作: 操作1: 1 x 表示将x插入到堆中 操作2: 2 输出该小根堆内的最小数 操作3: 3 删除该小根堆内的最小数 输入输出格式 输入格式: ...
- 数据结构知识总结(STL整理)
重要知识点 1.基础知识 #include<bits/stdc++.h> //万能头文件 #include< algorithm > //包含sort函数 运用sort实现多关 ...
- ACM-ICPC 2018 徐州赛区网络预赛 F Features Track(STL模拟)
https://nanti.jisuanke.com/t/31458 题意 有N个帧,每帧有K个动作特征,每个特征用一个向量表示(x,y).两个特征相同当且仅当他们在不同的帧中出现且向量的两个分量分别 ...
- PAT 1087 有多少不同的值(20)(STL—set)
1087 有多少不同的值(20 分) 当自然数 n 依次取 1.2.3.--.N 时,算式 ⌊n/2⌋+⌊n/3⌋+⌊n/5⌋ 有多少个不同的值?(注:⌊x⌋ 为取整函数,表示不超过 x 的最大自然数 ...
- URAL 1748. The Most Complex Number(反素数)
题目链接 题意 :给你一个n,让你找出小于等于n的数中因子个数最多的那个数,并且输出因子个数,如果有多个答案,输出数最小的那个 思路 : 官方题解 : (1)此题最容易想到的是穷举,但是肯定超时. ( ...
- CodeForces 993B Open Communication(STL 模拟)
https://codeforces.com/problemset/problem/993/b 这题不难,暴力就能过,主要是题意太难懂了 题意: 现在有两个人,每个人手中有一对数,第一个人手中的数是n ...
随机推荐
- win8vs2012创建自带sqlServer数据库出错
以前写程序的时候,一直使用的sqlite,今天心血来潮,想用vs2012连接自身带的数据库,结果就出现错误: 啊,看到这个错误,咱赶紧上网搜搜,啊,有关的日志也是比较少的,经过一番苦战之后,终于好了, ...
- UVA 10003 Cutting Sticks
题意:在给出的n个结点处切断木棍,并且在切断木棍时木棍有多长就花费多长的代价,将所有结点切断,并且使代价最小. 思路:设DP[i][j]为,从i,j点切开的木材,完成切割需要的cost,显然对于所有D ...
- 【C语言天天练(二四)】内存分配
引言: 对于C语言程序,了解它执行时在内存中是怎样分配的对于我们理解它的执行机制是很实用的.以下就总结一下C语言程序的一些内存分配知识. 一 一段C程序.编译连接后形成的可运行文件一般有代码段.数据段 ...
- 开源 java CMS - FreeCMS2.3 留言管理
原文地址:http://javaz.cn/site/javaz/site_study/info/2015/22027.html 项目地址:http://www.freeteam.cn/ 留言管理 管理 ...
- Android比较字符串是空的(isEmpty)
通常情况下,我们需要去推断一个字符串变量是否为空,今天,我特意做了一个小测试 StringUtils.java: package com.yx.equipment_collection.utils; ...
- 从零開始制作H5应用(4)——V4.0,增加文字并给文字加特效
之前,我们分三次完毕了我们第一个H5应用的三个迭代版本号: V1.0--简单页面滑动切换 V2.0--多页切换,透明过渡及交互指示 V3.0--加入loading,music及自己主动切换 这已经是一 ...
- MVC应用程序与单选列表
原文:MVC应用程序与单选列表 前几天,Insus.NET有在MVC应用程序中,练习了<MVC应用程序,动态创建单选列表(RadioButtonList)>http://www.cnblo ...
- 部署、收回和删除解决方式----STSADM和PowerShell
部署.收回和删除解决方式----STSADM和PowerShell 由于近期总是要部署wsp解决方式,所以常常要用到命令行或者PowerShell.所以有必要将命令集中放在这里.在部署 ...
- CSDN 四川大学线下编程比赛第二题:Peter的X
题目详情: http://student.csdn.net/mcs/programming_challenges Peter是个小男孩.他总是背不清26个英文字母. 于是,刁钻的英语老师给他布置了一个 ...
- 命令含执行JAVA程序
1.当类没有包名时 javac Test.java java Test 2.当有包名情况下 package com.me.Test; javac -d . Test.java java com.m ...