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 ...
随机推荐
- [页面模板框架对比] Apache Tiles VS Sitemesh
1. 原理对比 (1) Apache Tiles 顾名思义,Tile是瓷砖的意思,也就是说一个网页是由多个Tile组成的. 用户通过访问一个页面的Apache Tiles定义名,就可以访问一个由定义文 ...
- Linux统计文件/目录数量ls -l | grep "^-" | wc -l匹配开头和结尾
Linux统计文件数量 ls -l | grep "^-" | wc -l “^-” 一般文件 “^d” 目录文件 shell/vim中^表示开头 cat repatterns ...
- 人事管理系统 c语言版
int menu(){ printf("请按提示输入完毕操作!\n"); printf("1.查询员工信息\n"); printf("2.统计 ...
- Swift - 设置UIView的背景色和背景图片
1,使用UIColor的内置颜色设置背景色 1 2 var page = UIView() page.backgroundColor = UIColor.greenColor() 2,设置自定义颜色 ...
- WinDBG调试技巧
参考链接:http://wenku.baidu.com/view/4e58744dcf84b9d528ea7a42.html
- Go的String转码包
https://github.com/qiniu/iconv https://github.com/djimenez/iconv-go 这是与go不相干的转码包:https://github.com/ ...
- kill命令"-1"这个参数到底是杀进程还是reload?(转)
kill-1:重新读取一次参数的配置文件 (类似 reload) 这句话给我的感觉是把进程杀掉后重启进程,即 reload.而我查了下 man kill,-1 对应的 signal 是 SIGHUP, ...
- Linux几种关机(重启)相关命令
在linux下一些常用的关机/重启命令有shutdown.halt.reboot.及init,它们都可以达到重启系统的目的,但每个命令的内部工作过程是不同的,通过本文的介绍,希望你可以更加灵活的运用各 ...
- hadoop深入研究:(七)——压缩
转载请标明出处:hadoop深入研究:(七)——压缩 文件压缩主要有两个好处,一是减少了存储文件所占空间,另一个就是为数据传输提速.在hadoop大数据的背景下,这两点尤为重要,那么我现在就先来了解下 ...
- 对称加密算法DES,3重DES,TDEA,Blowfish,RC5,IDEA,AES。
对称加密算法:DES,3重DES,TDEA,Blowfish,RC5,IDEA,AES. 1.对称加密算法 1.1 定义 对称加密算法是应用较早的加密算法,技术成熟.在对称加密算法中,数据发信方将明文 ...