CF74A Room Leader 题解
Content
一场 CF 比赛有 \(n\) 个人,有 ABCDE 五道题目。在比赛过程中,参赛者还可以随时互相攻击,成功一次加 \(100\) 分,失败一次扣 \(50\)分,已知第 \(i\) 个人攻击成功了 \(plus_i\) 次,失败了 \(minus_i\) 次,并且 TA 五道题目的分数分别是 \(a_i,b_i,c_i,d_i,e_i\)。试判断出本场比赛的第一名。
Range
\(n,plus_i,minus_i\) 的范围:
\(1\leqslant n\leqslant 50,0\leqslant plus_i,minus_i\leqslant 50\)。
\(a_i,b_i,c_i,d_i,e_i\) 的范围:
\(150\leqslant a_i\leqslant 500,300\leqslant b_i\leqslant 1000,450\leqslant c_i\leqslant 1500,600\leqslant d_i\leqslant 2000,750\leqslant e_i\leqslant 2500\)。但是其中 \(a_i,b_i,c_i,d_i,e_i\) 中的任意一个都可以为 \(0\),代表五个问题中可能会有没解决出来的。
Solution
这道题目属于看完了以后立马就会有思路的,也就是说,我们可以用模拟的方法解决。
可以很明显的知道,第 \(i\) 为参赛者的得分就是 \(100\cdot plus_i-50\cdot minus_i+a_i+b_i+c_i+d_i+e_i\),计算完分数后再按照分数为关键字排序,输出第一位的名字就可以通过这道题目了。
Code
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
struct user {
string name;
int win, lose, ai, bi, ci, di, ei;
long long score;
bool operator < (const user& kkk) const {return score > kkk.score;}
}a[57];
int n;
int main() {
scanf("%d", &n);
for(int i = 1; i <= n; ++i) {
cin >> a[i].name;
scanf("%d%d%d%d%d%d%d", &a[i].win, &a[i].lose, &a[i].ai, &a[i].bi, &a[i].ci, &a[i].di, &a[i].ei);
a[i].score = a[i].win * 100 - a[i].lose * 50 + a[i].ai + a[i].bi + a[i].ci + a[i].di + a[i].ei;
}
sort(a + 1, a + n + 1);
cout << a[1].name;
return 0;
}
CF74A Room Leader 题解的更多相关文章
- [2015hdu多校联赛补题]hdu5378 Leader in Tree Land
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5378 题意:给你一棵n个结点的有根树.因为是有根树,那么每个结点可以指定以它为根的子树(后面讨论的子树 ...
- HDU-3974 Assign the task题解报告【dfs序+线段树】
There is a company that has N employees(numbered from 1 to N),every employee in the company has a im ...
- zookeeper源码分析之五服务端(集群leader)处理请求流程
leader的实现类为LeaderZooKeeperServer,它间接继承自标准ZookeeperServer.它规定了请求到达leader时需要经历的路径: PrepRequestProcesso ...
- Team Leader 你不再只是编码, 来炖一锅石头汤吧
h3{ color: #000; padding: 5px; margin-bottom: 10px; font-weight: bolder; background-color: #ccc; } h ...
- 【分布式】Zookeeper的Leader选举
一.前言 前面学习了Zookeeper服务端的相关细节,其中对于集群启动而言,很重要的一部分就是Leader选举,接着就开始深入学习Leader选举. 二.Leader选举 2.1 Leader选举概 ...
- 2016 华南师大ACM校赛 SCNUCPC 非官方题解
我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...
- noip2016十连测题解
以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #incl ...
- BZOJ-2561-最小生成树 题解(最小割)
2561: 最小生成树(题解) Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1628 Solved: 786 传送门:http://www.lyd ...
- Codeforces Round #353 (Div. 2) ABCDE 题解 python
Problems # Name A Infinite Sequence standard input/output 1 s, 256 MB x3509 B Restoring P ...
随机推荐
- request.setAttribute()和session.setAttribute()的区别详解
我们在Servlet和页面间传值时,经常会用到request.setAttribute()和session.setAttribute(),下面是两段示例用法 request.setAttribute( ...
- gitee+typro+picgo搭建博客图床
gitee+typro+picgo搭建博客图床 前提环境 typro.picgo.nodejs 直接在官网下载即可 下载完成后,打开picgo 安装插件gitee-uploader 1.1-2即可显示 ...
- python 内置模块续(二)
目录 python 内置模块补充 1.hashlib模块 简易使用: 高级使用: 进阶使用: 加盐处理: 校验文件一致性 2.logging日志模块 日志等级 常用处理 "四大天王" ...
- 洛谷 P4707 - 重返现世(扩展 Min-Max 容斥+背包)
题面传送门 首先看到这种求形如 \(E(\max(T))\) 的期望题,可以套路地想到 Min-Max 容斥 \(\max(S)=\sum\limits_{T\subseteq S}(-1)^{|T| ...
- netty系列之:手持framecodec神器,创建多路复用http2客户端
目录 简介 配置SslContext 客户端的handler 使用Http2FrameCodec Http2MultiplexHandler和Http2MultiplexCodec 使用子channe ...
- 在服务端应用中如何获得客户端 IP
如果有 x-forwarded-for 的请求头,则取其中的第一个 IP,否则取建立连接 socket 的 remoteAddr. 而 x-forwarded-for 基本已成为了基于 proxy 的 ...
- 打破砂锅问到底!HTTP和HTTPS详解
HTTP 引自维基百科HTTP:超文本传输协议(英文:HyperText Transfer Protocol,缩写:HTTP)是一种用于分布式.协作式和超媒体信息系统的应用层协议.HTTP是万维网的数 ...
- 集合类——Map集合、Properties属性文件操作
1.Map集合 Collection集合的特点是每次进行单个对象的保存,若要对一对对象来进行保存就只能用Map集合来保存.即Map集合中一次可以保存两个对象,且这两个对象的关系是key = value ...
- linux 常用清空文件方法
1.vim 编辑器 vim /tmp/file :1,$d 或 :%d 2.cat 命令 cat /dev/null > /tmp/file
- When does compiler create default and copy constructors in C++?
In C++, compiler creates a default constructor if we don't define our own constructor (See this). Co ...