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. .NET Winform 将引用的dll文件集成到exe中(转)

    Winform程序经常需要引用一些第三方dll文件,这些dll在发布后与exe文件保存在同一目录下,虽然将dll文件集成到exe中会增大文件尺寸,但程序目录会相对整洁. 下面介绍一种比较简单的集成方法 ...

  2. Kubernetes TensorFlow 默认 特定 集群管理器

    Our goal is to foster an ecosystem of components and tools that relieve the burden of running applic ...

  3. Hive 实际上对于所存储的文件的完整性以及数据内容是否和表结构一致无支配力

    数据位于hdfs路径下 load data into Table t1 load 执行的是复制文件的操作 create Table partitioned by () 创建了分区目录

  4. 题解 P1387 【最大正方形】

    传送门 搞不清楚为什么这一题要DP . . . . . . 思路: \(n\le100\),考虑暴力. 要求一大块区间内都是1,考虑前缀和. 在矩阵中求一个符合条件的子矩阵,考虑\(n^3\)的&qu ...

  5. DAICO模式到底是什么?

    自从V神提出DAICO以来,已经有项目围绕DAICO模式落地,但是DAICO到底是什么呢? 所谓DAIC0,其实就是DAO+IC0. DAO是DistributedAutonomous Organiz ...

  6. SAP-Function_01

    TH_POPUP –在特定用户屏幕上显示一个系统消息 1 . 函数WS_UPLOAD     功能﹕将TXT文件转换成SAP中的内表定义的数据表格文件    注意﹕1 函数将按参数 data_tab  ...

  7. Database: key

    super-key: Any key that has more columns than necessary to uniquely identify each row in the table i ...

  8. Ubuntu/CentOS下使用脚本自动安装 Docker

    Ubuntu.Debian 系列安装 Docker 系统要求 Docker 支持以下版本的 Ubuntu 和 Debian 操作系统: Ubuntu Xenial 16.04 (LTS) Ubuntu ...

  9. mini2440 uboot烧写uImage

    mini2440下烧写u-boot后,就可以用u-boot烧写linux内核了. 安装mkimage工具: apt-get install u-boot-tools 解压缩官方mini2440 lin ...

  10. WINFROM中自定义控件之绑定数据即时更新

    相信在WINFROM中写自定义控件或者用户控件,很多人都多多少少用过点 最近发现一个用户控件,绑定的数据源没办法自动更新,其实以前处理过这类的问题,可是这次遇到又花了1个多小时,所以决定记下来 在用户 ...