gpa

链接:https://www.nowcoder.com/acm/contest/143/A
来源:牛客网

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 262144K,其他语言524288K
Special Judge, 64bit IO Format: %lld

题目描述

Kanade selected n courses in the university. The academic credit of the i-th course is s[i] and the score of the i-th course is c[i].

At the university where she attended, the final score of her is 

Now she can delete at most k courses and she want to know what the highest final score that can get.

输入描述:

The first line has two positive integers n,k

The second line has n positive integers s[i]

The third line has n positive integers c[i]

输出描述:

Output the highest final score, your answer is correct if and only if the absolute error with the standard answer is no more than 10

-5

输入例子:
3 1
1 2 3
3 2 1
输出例子:
2.33333333333

-->

示例1

输入

复制

3 1
1 2 3
3 2 1

输出

复制

2.33333333333

说明

Delete the third course and the final score is 

备注:

1≤ n≤ 10

5


0≤ k < n

1≤ s[i],c[i] ≤ 10

3

 
 
 
 
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define MAX 100005
#define INF 0x3f3f3f3f
#define MOD 1000000007
using namespace std;
typedef long long ll; double s[MAX],c[MAX],cnt[MAX]; int main()
{
int n,k,i;
scanf("%d%d",&n,&k);
for(i=;i<=n;i++){
scanf("%lf",&s[i]);
}
for(i=;i<=n;i++){
scanf("%lf",&c[i]);
}
double l=,r=;
while(r-l>0.000001){
double mid=(l+r)/;
for(i=;i<=n;i++){
cnt[i]=s[i]*c[i]-mid*s[i];
}
sort(cnt+,cnt+n+);
double fx=;
for(i=k+;i<=n;i++){
fx+=cnt[i];
}
if(fx>=) l=mid;
else r=mid;
}
printf("%f\n",l);
return ;
}

牛客多校5 A-gpa(01分数规划)的更多相关文章

  1. P2877 [USACO07JAN]牛校Cow School(01分数规划+决策单调性分治)

    P2877 [USACO07JAN]牛校Cow School 01分数规划是啥(转) 决策单调性分治,可以解决(不限于)一些你知道要用斜率优化却不会写的问题 怎么证明?可以暴力打表 我们用$ask(l ...

  2. POJ 2728 Desert King (01分数规划)

    Desert King Time Limit: 3000MS   Memory Limit: 65536K Total Submissions:29775   Accepted: 8192 Descr ...

  3. 2019牛客多校第二场 A Eddy Walker(概率推公式)

    2019牛客多校第二场 A Eddy Walker(概率推公式) 传送门:https://ac.nowcoder.com/acm/contest/882/A 题意: 给你一个长度为n的环,标号从0~n ...

  4. 2019牛客多校第一场 I Points Division(动态规划+线段树)

    2019牛客多校第一场 I Points Division(动态规划+线段树) 传送门:https://ac.nowcoder.com/acm/contest/881/I 题意: 给你n个点,每个点有 ...

  5. 牛客多校第一场 B Inergratiion

    牛客多校第一场 B Inergratiion 传送门:https://ac.nowcoder.com/acm/contest/881/B 题意: 给你一个 [求值为多少 题解: 根据线代的知识 我们可 ...

  6. 牛客多校第三场 F Planting Trees

    牛客多校第三场 F Planting Trees 题意: 求矩阵内最大值减最小值大于k的最大子矩阵的面积 题解: 矩阵压缩的技巧 因为对于我们有用的信息只有这个矩阵内的最大值和最小值 所以我们可以将一 ...

  7. 牛客多校第三场 G Removing Stones(分治+线段树)

    牛客多校第三场 G Removing Stones(分治+线段树) 题意: 给你n个数,问你有多少个长度不小于2的连续子序列,使得其中最大元素不大于所有元素和的一半 题解: 分治+线段树 线段树维护最 ...

  8. 牛客多校第四场sequence C (线段树+单调栈)

    牛客多校第四场sequence C (线段树+单调栈) 传送门:https://ac.nowcoder.com/acm/contest/884/C 题意: 求一个$\max {1 \leq l \le ...

  9. 牛客多校第3场 J 思维+树状数组+二分

    牛客多校第3场 J 思维+树状数组+二分 传送门:https://ac.nowcoder.com/acm/contest/883/J 题意: 给你q个询问,和一个队列容量f 询问有两种操作: 0.访问 ...

随机推荐

  1. sqlite与sqlserver区别

    1.查询时把两个字段拼接在一起 --sqlserver-- select Filed1+'@'+Filed2 from table --sqlite-- select Filed1||'@'||Fil ...

  2. Html控件和Web控件(转)

    作为一名ASP.NET的初学者,了解并且区别一些混淆概念是很必须的,今天这篇博文 就是主要向大家介绍一下Html控件和Web控件.在ASP.net中,用户界面控件主要就是 Html控件和Web控件,在 ...

  3. 查看远程分支的log

    1 将远程分支的commit fetch到本地 git fetch 2 查看远程分支的log git log <remote-branch>

  4. SQL2005数据库放在C盘,结果C盘满了,怎么搞到D盘

    首先,你需要将自己所建立的数据库从SQL2005中分离出来,然后按照自己的存储路径找到自己所建数据库存储的位置,把它剪切到D盘就可以了.(mdf,ldf都应该考过去,自己建立路径存储就可以,再次打开的 ...

  5. JVM性能分析工具详解--MAT等

    获得堆转储文件 巧妇难为无米之炊,我们首先需要获得一个堆转储文件.为了方便,本文采用的是 Sun JDK 6.通常来说,只要你设置了如下所示的 JVM 参数: -XX:+HeapDumpOnOutOf ...

  6. (C)位字段(bit-field)

    位字段(bit-field) 在存储空间很宝贵的情况下,有可能需要将多个对象保存在一个机器字中,一种常用的方法是:使用类似于编译器符号表的单个二进制位标志集合,外部强加的数据格式(如设备接口等寄存器) ...

  7. Android Weekly Notes Issue #255

    Android Weekly Issue #255 April 30th, 2017 Android Weekly Issue #255 本期内容包括: 一种在RxJava中显示loading/con ...

  8. mvc Bundling 学习记录(一)

    参考博客:http://www.cnblogs.com/xwgli/p/3296809.html 这里要详细记录的是对于现有MVC项目进行Bundling功能 1  如果没有System.Web.Op ...

  9. g2o求解BA 第10章

    1.g2o_bal_class.h1.1 projection.hg2o还是用图模型和边,顶点就是相机和路标,边就是观测,就是像素坐标.只不过这里的相机是由旋转(3个参数,轴角形式,就是theta*n ...

  10. LightOJ - 1287 Where to Run —— 期望、状压DP

    题目链接:https://vjudge.net/problem/LightOJ-1287 1287 - Where to Run    PDF (English) Statistics Forum T ...