Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

用右端点r就ac

Posted by 2468216537 at 2022-03-30 21:49:26 on Problem 1064
#include <iostream>
using namespace std;
const int N = 10010;
double lines[N];
int n,k;

bool check(double mid){
    int cnt = 0;
    for (int i = 0;i < n;i++)
        cnt += (int)(lines[i]/mid);
    return cnt >= k;
}

int main(){
    cin >> n >> k;
    for (int i = 0; i < n; i++ ) {
        cin >> lines[i];
    }
    double l = 0,r = 1e5,mid,eps = 1e-8;
    while (l + eps < r){
        mid = (l + r)/2;
        if (check(mid)) l = mid;
        else r = mid;
    }
    printf("%.2lf\n",(int)(r*100)/100.0);
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator