zoj 3068 Dropping tests

zoj 3068 Dropping tests,第1张

zoj 3068 Dropping tests
#include <cstdio>#include <algorithm>using namespace std;int main(){    int n, k;    double l, r, mid, s;    static int a[1024], b[1024];    static double v[1024];    while (scanf("%d%d", &n, &k) != EOF && n > 0) {        for (int i = 0; i < n; i++) { scanf("%d", &a[i]);        }        for (int i = 0; i < n; i++) { scanf("%d", &b[i]);        }        l = 0;        r = 1;        while (r - l > 1e-8) { mid = (l + r) / 2; for (int i = 0; i < n; i++) {     v[i] = a[i] - mid * b[i]; } s = 0; sort(v, v + n); for (int i = k; i < n; i++) {     s += v[i]; } if (s >= 0) {     l = mid; } else {     r = mid; }        }        printf("%.0lfn", 100 * l);    }    return 0;}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4918787.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存