题目链接: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(贪心+思维)的更多相关文章

  1. 【codeforces 807D】Dynamic Problem Scoring

    [题目链接]:http://codeforces.com/contest/807/problem/D [题意] 给出n个人的比赛信息; 5道题 每道题,或是没被解决->用-1表示; 或者给出解题 ...

  2. codeforces 807 E. Prairie Partition(贪心+思维)

    题目链接:http://codeforces.com/contest/807/problem/E 题意:已知每个数都能用x=1 + 2 + 4 + ... + 2k - 1 + r (k ≥ 0, 0 ...

  3. 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 ...

  4. 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 ...

  5. Codeforces Round #546 (Div. 2) D 贪心 + 思维

    https://codeforces.com/contest/1136/problem/D 贪心 + 思维 题意 你面前有一个队列,加上你有n个人(n<=3e5),有m(m<=个交换法则, ...

  6. AC日记——Dynamic Problem Scoring codeforces 807d

    Dynamic Problem Scoring 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <io ...

  7. codeforces 798 C. Mike and gcd problem(贪心+思维+数论)

    题目链接:http://codeforces.com/contest/798/problem/C 题意:给出一串数字,问如果这串数字的gcd大于1,如果不是那么有这样的操作,删除ai, ai + 1 ...

  8. CodeForces 518E Arthur and Questions(贪心 + 思维)题解

    题意:给你a1~an,k,要求a1 + ... + ak < a2 + .... + ak+1 < a3 + ... + ak+2 <...,然后这里的ai有可能是?,要求你填?的数 ...

  9. 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas

    题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...

随机推荐

  1. golang文档、中文、学习文档

    Golang中文文档地址 http://zh-golang.appspot.com/doc/ Golang非英文文档地址: https://github.com/golang/go/wiki/NonE ...

  2. java基础学习_io流之FileInputStream

    一.FileInputStream属性: /* File Descriptor - handle to the open file */private final FileDescriptor fd; ...

  3. 阿里云Linxu下的Mysql安装与配置

    说明:本文主要详细介绍了关于如何在阿里云ECS服务器上安装并配置Mysql 环境:Centos 7版本,阿里云部署好系统后会默认安装mariadb数据库 1.删除阿里云自带的MariaDB # rpm ...

  4. Go slice:切片的“陷阱”和本质

    文章说明 总结了go语言中切片slice的特殊性和使用时的注意事项. 个人理解,不足之处欢迎指出. slice:切片,是go语言中一种常用的数据结构,基于数组构建,表示相同数据类型的集合. 数组 Go ...

  5. WPF后台设置颜色字体等

    Button TempButton = new Button();                                                TempButton.Tag = “按 ...

  6. Redhat 离线安装 Docker (Community from binaries)

    需求 在离线环境安装Docker (Community版),因为Enterprise版要花钱.当然资金充裕的客户可参考https://docs.docker.com/install/linux/doc ...

  7. centos虚拟机配置静态ip

    昨天在配置虚拟机的时候因为之前没有设置静态IP,而是使用DHCP动态分配的,导致关机后下次开机虚拟机的ip是随机变动的.严重影响了工作体验啊,遂设置静态ip以保全! 虚拟机使用的是CentOS6.5, ...

  8. 5月29日 Java性能调优指南 读后感

    并行垃圾收集器 串行垃圾收集器 并发标记清除(CMS)垃圾收集器 Garbage First(G1)垃圾收集器 没有深入的学习G1的原理,只是看了大概的思想; SA工具:待学习

  9. [实践]activemq安全设置 设置admin的用户名和密码

    (1)打开/opt/app/amq/apache-activemq-5.9.0/conf/jetty.xml 找到 将property name为authenticate的属性value=" ...

  10. HDU 4635 (完全图 和 有向图缩点)

    题目链接:HDU  4635 题目大意: 给你一个有向图,加有向边,使得这个图是简单有向图.问你最多加多少条有向边. 简单有向图: 1.不存在有向重边. 2.不存在图循环.(注意是不存在 “图” 循环 ...