codeforces 807 D. Dynamic Problem Scoring(贪心+思维)
题目链接:http://codeforces.com/contest/807/problem/D
题意:对于动态计分的 Codeforces Round ,已知每题的 score 是根据 Round 参加人数和该题过题人数计算,两者之比结合上图得出该题的分数。某人在该题的得分为 score*(1−t/250) 其中 t 表示通过该题的时间。
已知参加该场比赛的所有参加者的过题情况(包括 Vasya 和 Petya),问如何通过增加新的参赛者(尽量少),使得 Vasya 的最终得分高于 Petya。
题解:首先预算一下最多需要多少人,3000*4/12=10000,最多不超过10000人。
然后就枚举一遍0~10000,需要注意的是几种情况
if(T[1].a[j] == -1) {
rate[j] = 1.0 * sum[j] / (n + i);
}
else {
if(T[1].a[j] > T[2].a[j] && T[2].a[j] != -1) {
rate[j] = 1.0 * (sum[j] + i) / (n + i);
}
else {
rate[j] = 1.0 * sum[j] / (n + i);
}
}
这些情况考虑了就行了。
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define inf 0X3f3f3f3f
using namespace std;
struct TnT {
int a[6];
}T[200];
int main() {
int n;
double rate[6];
int sum[6];
memset(sum , 0 , sizeof(sum));
scanf("%d" , &n);
for(int i = 1 ; i <= n ; i++) {
for(int j = 1 ; j <= 5 ; j++) {
scanf("%d" , &T[i].a[j]);
if(T[i].a[j] >= 0) {
sum[j]++;
}
}
}
int flag = 0;
for(int i = 1 ; i <= 5 ; i++) {
if(T[2].a[i] > T[1].a[i] || (T[2].a[i] == -1 && T[1].a[i] != -1)) {
flag = 1;
break;
}
}
if(!flag) {
printf("-1\n");
}
else {
int ans = -1;
for(int i = 0 ; i <= 10000 ; i++) {
double sum1 = 0 , sum2 = 0;
for(int j = 1 ; j <= 5 ; j++) {
if(T[1].a[j] == -1) {
rate[j] = 1.0 * sum[j] / (n + i);
}
else {
if(T[1].a[j] > T[2].a[j] && T[2].a[j] != -1) {
rate[j] = 1.0 * (sum[j] + i) / (n + i);
}
else {
rate[j] = 1.0 * sum[j] / (n + i);
}
}
}
for(int j = 1 ; j <= 5 ; j++) {
if(rate[j] <= 1.0 && rate[j] > 1.0 / 2) {
if(T[1].a[j] >= 0) sum1 += 1.0 * 500 * (1.0 - 1.0 * T[1].a[j] / 250);
if(T[2].a[j] >= 0) sum2 += 1.0 * 500 * (1.0 - 1.0 * T[2].a[j] / 250);
}
if(rate[j] <= 1.0 / 2 && rate[j] > 1.0 / 4) {
if(T[1].a[j] >= 0) sum1 += 1.0 * 1000 * (1.0 - 1.0 * T[1].a[j] / 250);
if(T[2].a[j] >= 0) sum2 += 1.0 * 1000 * (1.0 - 1.0 * T[2].a[j] / 250);
}
if(rate[j] <= 1.0 / 4 && rate[j] > 1.0 / 8) {
if(T[1].a[j] >= 0) sum1 += 1.0 * 1500 * (1.0 - 1.0 * T[1].a[j] / 250);
if(T[2].a[j] >= 0) sum2 += 1.0 * 1500 * (1.0 - 1.0 * T[2].a[j] / 250);
}
if(rate[j] <= 1.0 / 8 && rate[j] > 1.0 / 16) {
if(T[1].a[j] >= 0) sum1 += 1.0 * 2000 * (1.0 - 1.0 * T[1].a[j] / 250);
if(T[2].a[j] >= 0) sum2 += 1.0 * 2000 * (1.0 - 1.0 * T[2].a[j] / 250);
}
if(rate[j] <= 1.0 / 16 && rate[j] > 1.0 / 32) {
if(T[1].a[j] >= 0) sum1 += 1.0 * 2500 * (1.0 - 1.0 * T[1].a[j] / 250);
if(T[2].a[j] >= 0) sum2 += 1.0 * 2500 * (1.0 - 1.0 * T[2].a[j] / 250);
}
if(rate[j] <= 1.0 / 32 && rate[j] > 0.0) {
if(T[1].a[j] >= 0) sum1 += 1.0 * 3000 * (1.0 - 1.0 * T[1].a[j] / 250);
if(T[2].a[j] >= 0) sum2 += 1.0 * 3000 * (1.0 - 1.0 * T[2].a[j] / 250);
}
}
if(sum1 > sum2) {
ans = i;
break;
}
}
printf("%d\n" , ans);
}
return 0;
}
codeforces 807 D. Dynamic Problem Scoring(贪心+思维)的更多相关文章
- 【codeforces 807D】Dynamic Problem Scoring
[题目链接]:http://codeforces.com/contest/807/problem/D [题意] 给出n个人的比赛信息; 5道题 每道题,或是没被解决->用-1表示; 或者给出解题 ...
- codeforces 807 E. Prairie Partition(贪心+思维)
题目链接:http://codeforces.com/contest/807/problem/E 题意:已知每个数都能用x=1 + 2 + 4 + ... + 2k - 1 + r (k ≥ 0, 0 ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) D - Dynamic Problem Scoring
地址:http://codeforces.com/contest/807/problem/D 题目: D. Dynamic Problem Scoring time limit per test 2 ...
- Codeforces Round #412 Div. 2 补题 D. Dynamic Problem Scoring
D. Dynamic Problem Scoring time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- Codeforces Round #546 (Div. 2) D 贪心 + 思维
https://codeforces.com/contest/1136/problem/D 贪心 + 思维 题意 你面前有一个队列,加上你有n个人(n<=3e5),有m(m<=个交换法则, ...
- AC日记——Dynamic Problem Scoring codeforces 807d
Dynamic Problem Scoring 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <io ...
- codeforces 798 C. Mike and gcd problem(贪心+思维+数论)
题目链接:http://codeforces.com/contest/798/problem/C 题意:给出一串数字,问如果这串数字的gcd大于1,如果不是那么有这样的操作,删除ai, ai + 1 ...
- CodeForces 518E Arthur and Questions(贪心 + 思维)题解
题意:给你a1~an,k,要求a1 + ... + ak < a2 + .... + ak+1 < a3 + ... + ak+2 <...,然后这里的ai有可能是?,要求你填?的数 ...
- 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas
题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...
随机推荐
- 精准营销、批量提取QQ群成员号码
有时我们在做精准营销时,需要从社群里提取群成员的QQ号,群发邮件,常规的做法是手工一个个复制粘贴,这样的效率无疑是很低的,下面我来分享一个批量获取社群的QQ号方法. 需要具备以下工具: 1.大量精准Q ...
- 【Python】Django 的邮件引擎用法详解!!(调用163邮箱为例)
1. send_mall()方法介绍 位置: 在django.core.mail模块提供了send_mail()来发送邮件. 方法参数: send_mail(subject, message, fro ...
- Selenium模拟登陆百度贴吧
Selenium模拟登陆百度贴吧 from selenium import webdriver from time import sleep from selenium.webdriver.commo ...
- sqoop 密码别名模式 --password-alias
sqoop要使用别名模式隐藏密码 1.首先使用命令创建别名 hadoop credential create xiaopengfei -provider jceks://hdfs/user/pass ...
- zookeeper 集群配置
安装前要先确保配置好 jdk,这里不在讲述 一. 将zookeeper 安装包下载到你想要的目录 下载地址:http://mirrors.hust.edu.cn/apache/zookeeper/ m ...
- dotnetcore 与 hbase 之二——thrift 客户端的制作
说明 在上一篇文章dotnetcore 与 hbase 之一--hbase 环境准备结束后,我们已经有了 hbase 数据库环境.接下来就可以利用 thrift 生成 c# hbase 客户端了.如果 ...
- Kafka基本知识入门(一)
1. 基础知识 有关RabbitMQ,RocketMQ,Kafka的区别这个网上很多,了解一下区别性能,分清什么场景使用.分布式环境下的消息中间件Kafka做的比较不错,在分布式环境下使用频繁,我也不 ...
- 世界十大OTA公司盘点
世界十大OTA公司盘点 文/刘照慧(执惠旅游联合创始人,首发百度百家) 全球在线旅游公司(OTA)经过多年发展,已经形成较为成熟的商业模式,各大巨头跑马圈地,格局初现, 这两篇文章就梳理出全球按市值( ...
- arukas 樱花免费docker容器获取IP和端口
arukas 樱花免费docker容器,可以安装linux系统,但是每隔一段时间会重启,重启以后IP地址和映射到公网的端口都会变,获取IP和端口,我研究了很久终于找到了C#获取IP和端口的办法,用来搭 ...
- ubuntu 输出 log 基础
自定义日志文件 nohup your_command > my_nohup.log 2>&1 & #(将日志输出在my_nohup.log文件中,并将stderr重定向至s ...