LA 8043. ACM-ICPC World Finals 2017 E. Need for Speed

二分

LA上的题目居然和原题有差别!变成了多组数据

下面这个程序是按原题写的

#include <iostream>
#include <cstdio>
#include <algorithm>

int main() {
  int n, t;
  std::cin >> n >> t;

  double d[1000], s[1000];
  for (int i = 0; i < n; i++)
    std::cin >> d[i] >> s[i];

  double l = -*std::min_element(s, s + n), r = 1001000;
  while (l + 2e-10 <= r) {
    double mid = l + (r - l) / 2, t_ = 0;

    for (int i = 0; i < n; i++)
      t_ += d[i] / (s[i] + mid);

    if (t_ < t)
      r = mid;
    else
      l = mid;
  }
  printf("%.9lf\n", l);
  return 0;
}

原文地址:https://www.cnblogs.com/P6174/p/8137392.html

时间: 2024-10-18 03:16:05

LA 8043. ACM-ICPC World Finals 2017 E. Need for Speed的相关文章

Puzzle, ACM/ICPC World Finals 1993, UVa227

有一个5*5的网格,其中恰好有一个格子是空的,其他格子各有一个字母.一共有4种指令:A, B, L, R,分别表示把空格上.下.左.右的相邻字母移到空格中.输入初始网格和指令序列(以数字0结束),输出指令执行完毕后的网格.如果有非法指令,应输出"Thispuzzle has no final configuration.",例如,图3-5中执行ARRBBL0后,效果如图3-6所示. 写的比较简陋,先写了容器,然后填充,写移动条件. 以下是用C写的源码: #include<stdi

[UVa 213]Message Decoding,ACM/ICPC World Finals 1991 信息解码

A children's board game consists of a square array of dots that contains lines connecting some of the pairs of adjacent dots. One part of the game requires that the players count the number of squares of certain sizes that are formed by these lines.

[算法竞赛入门经典] Crossword Answers ACM/ICPC World Finals 1994,UVa232

Description A crossword puzzle consists of a rectangular grid of black and white squares and two lists of definitions (or descriptions). One list of definitions is for "words" to be written left to right across white squares in the rows and the

[算法竞赛入门经典]Message Decoding,ACM/ICPC World Finals 1991,UVa213

Description Some message encoding schemes require that an encoded message be sent in two parts. The first part, called the header, contains the characters of the message. The second part contains a pattern that represents the message. You must write

信息解码,ACM/ICPC World Finals 1991

问题 考虑下面的01串序列: 0, 00, 01, 10, 00, 001, 010, 011, 100, 101, 110, 0000, 0001, --, 1101, 1110, 00000, -- 首先是长度为1的串,然后是长度为2的串,依次推类.如果看成二进制,相同长度的后一个串等于前一个串加1.上述序列中不存在全为1的串: 编写一个解码程序.首先输入一个编码头(例如 AB#TANCnrtXc), 则上述序列的每个串依次对应编码头的每个字符.例如0对应A,00对应B,01对应#,--:

hdu6206 Apple 2017 ACM/ICPC Asia Regional Qingdao Online

地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6206 题目: Apple Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 530    Accepted Submission(s): 172 Problem Description Apple is Taotao's favouri

2017 ACM/ICPC Asia Regional Shenyang Online spfa+最长路

transaction transaction transaction Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others)Total Submission(s): 1496    Accepted Submission(s): 723 Problem Description Kelukin is a businessman. Every day, he travels arou

World Finals 2017爆OJ记

Day-Inf: 去年China-Final一道数据结构题的FB送我进WF. 今年课表意外地满,好几天都是早上8点一直上课上到晚上9点,作业也相对较多.敝队大约每个星期只能训练一个下午,有时候甚至一整个星期都没有机会训练. 除去ICPC Camp,今年大概只组队训练了7场,浙江省赛还因为内存原因少过一道动态凸包.直到WF前,我也就是单人刷完了WF2014.WF2015以及绝大部分WF2016,训练时间实在是不够.队友也已经大四,整个学期都很忙,水平肯定有所下降,在WF前一周稍微写了写题找找状态.

《ACM/ICPC 算法训练教程》读书笔记一之数据结构(堆)

书籍简评:<ACM/ICPC 算法训练教程>这本书是余立功主编的,代码来自南京理工大学ACM集训队代码库,所以小编看过之后发现确实很实用,适合集训的时候刷题啊~~,当时是听了集训队final的意见买的,感觉还是不错滴. 相对于其他ACM书籍来说,当然如书名所言,这是一本算法训练书,有着大量的算法实战题目和代码,尽管小编还是发现了些许错误= =,有部分注释的语序习惯也有点不太合我的胃口.实战题目较多是比较水的题,但也正因此才能帮助不少新手入门,个人认为还是一本不错的算法书,当然自学还是需要下不少