QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#321477 | #8214. Huge Oil Platform | ucup-team296 | TL | 6001ms | 2444kb | Rust | 38.2kb | 2024-02-04 20:18:35 | 2024-02-04 20:18:35 |
Judging History
answer
//
pub mod solution {
//{"name":"h","group":"Manual","url":"","interactive":false,"timeLimit":2000,"tests":[{"input":"","output":""},{"input":"","output":""},{"input":"","output":""}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"h"}}}
#[allow(unused)]
use crate::dbg;
use crate::algo_lib::geometry::point::PointT;
use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::output::Output;
use crate::algo_lib::seg_trees::bottom_up_seg_tree::BottomUpSegTree;
use crate::algo_lib::seg_trees::seg_tree_trait::SegTreeNode;
type Point = PointT<i64>;
#[derive(Clone, Copy, Debug)]
struct Node {
pref: f64,
suf: f64,
all: f64,
max: f64,
}
const NEG_INF: f64 = -1e18;
impl Default for Node {
fn default() -> Self {
Self {
pref: NEG_INF,
suf: NEG_INF,
all: 0.0,
max: 0.0,
}
}
}
impl SegTreeNode for Node {
fn join_nodes(l: &Self, r: &Self, _context: &Self::Context) -> Self {
Self {
pref: (l.pref + r.all).max(r.pref),
suf: (r.suf + l.all).max(l.suf),
all: l.all + r.all,
max: l.max.max(r.max).max(l.pref + r.suf),
}
}
fn apply_update(node: &mut Self, update: &Self::Update) {
todo!()
}
fn join_updates(current: &mut Self::Update, add: &Self::Update) {
todo!()
}
type Update = ();
type Context = ();
}
fn calc_abc(p: Point, q: Point) -> (i64, i64, i64) {
let a = q.x - p.x;
let b = q.y - p.y;
let c = -a * p.x - b * p.y;
(a, b, c)
}
fn solve(input: &mut Input, out: &mut Output, _test_case: usize) {
let n = input.usize();
let mut pts = vec![];
let mut w = vec![];
for _ in 0..n {
pts.push(Point::new(input.i64(), input.i64()));
w.push(input.f64());
}
let mut res = 0.0f64;
for i in 0..n {
res = res.max(w[i]);
}
let mut x_pos = vec![usize::MAX; n];
let mut inside = vec![];
let mut calc = |p: Point, q: Point| -> f64 {
inside.clear();
let q2 = p + (q - p).rotate_ccw();
let (a, b, c) = calc_abc(p, q2);
for i in 0..n {
let dy = pts[i].x * a + pts[i].y * b + c;
if dy >= 0 {
inside.push(i);
}
}
let (ax, bx, cx) = calc_abc(p, q);
inside.sort_by_key(|&i| pts[i].x * ax + pts[i].y * bx);
for idx in 0..inside.len() {
x_pos[inside[idx]] = idx;
}
let (ay, by, cy) = calc_abc(p, q2);
inside.sort_by_key(|&i| pts[i].x * ay + pts[i].y * by);
let mut res = 0.0f64;
let x_coef = 1.0 / (Point::dist2(&p, &q) as f64).sqrt();
let y_coef = 1.0 / (Point::dist2(&p, &q2) as f64).sqrt();
let mut st = BottomUpSegTree::new(inside.len(), |_| Node::default());
for &i in inside.iter() {
let mut real_x = (pts[i].x * ax + pts[i].y * bx) as f64;
real_x *= x_coef;
let mut real_y = (pts[i].x * ay + pts[i].y * by + cy) as f64;
real_y *= y_coef;
let new_node = Node {
pref: w[i] + 2.0 * real_x,
suf: w[i] - 2.0 * real_x,
all: w[i],
max: w[i],
};
st.update_point(x_pos[i], new_node);
let cur_res = st.get(0..inside.len()).max - 2.0 * real_y;
res = res.max(cur_res);
}
res
};
for i in 0..n {
for j in 0..n {
if i == j {
continue;
}
{
let cur = calc(pts[i], pts[j]);
res = res.max(cur);
}
}
}
out.println(res);
}
pub(crate) fn run(mut input: Input, mut output: Output) -> bool {
solve(&mut input, &mut output, 1);
output.flush();
true
}
}
pub mod algo_lib {
pub mod collections {
pub mod array_2d {
use crate::algo_lib::io::output::Output;
use crate::algo_lib::io::output::Writable;
use crate::algo_lib::misc::num_traits::Number;
use std::io::Write;
use std::ops::Index;
use std::ops::IndexMut;
use std::ops::Mul;
// TODO: implement good Debug
#[derive(Clone, Debug)]
pub struct Array2D<T> {
rows: usize,
cols: usize,
v: Vec<T>,
}
pub struct Iter<'a, T> {
array: &'a Array2D<T>,
row: usize,
col: usize,
}
impl<T> Array2D<T>
where
T: Clone,
{
#[allow(unused)]
pub fn new(empty: T, rows: usize, cols: usize) -> Self {
Self {
rows,
cols,
v: vec![empty; rows * cols],
}
}
pub fn new_f(rows: usize, cols: usize, mut f: impl FnMut(usize, usize) -> T) -> Self {
let mut v = Vec::with_capacity(rows * cols);
for r in 0..rows {
for c in 0..cols {
v.push(f(r, c));
}
}
Self { rows, cols, v }
}
pub fn rows(&self) -> usize {
self.rows
}
#[allow(clippy::len_without_is_empty)]
pub fn len(&self) -> usize {
self.rows()
}
pub fn cols(&self) -> usize {
self.cols
}
pub fn swap(&mut self, row1: usize, row2: usize) {
assert!(row1 < self.rows);
assert!(row2 < self.rows);
if row1 != row2 {
for col in 0..self.cols {
self.v.swap(row1 * self.cols + col, row2 * self.cols + col);
}
}
}
pub fn transpose(&self) -> Self {
Self::new_f(self.cols, self.rows, |r, c| self[c][r].clone())
}
pub fn iter(&self) -> Iter<T> {
Iter {
array: self,
row: 0,
col: 0,
}
}
pub fn pref_sum(&self) -> Self
where
T: Number,
{
let mut res = Self::new(T::ZERO, self.rows + 1, self.cols + 1);
for i in 0..self.rows {
for j in 0..self.cols {
let value = self[i][j] + res[i][j + 1] + res[i + 1][j] - res[i][j];
res[i + 1][j + 1] = value;
}
}
res
}
}
impl<T> Writable for Array2D<T>
where
T: Writable,
{
fn write(&self, output: &mut Output) {
for r in 0..self.rows {
self[r].write(output);
output.write_all(&[b'\n']).unwrap();
}
}
}
impl<T> Index<usize> for Array2D<T> {
type Output = [T];
fn index(&self, index: usize) -> &Self::Output {
&self.v[(index) * self.cols..(index + 1) * self.cols]
}
}
impl<T> IndexMut<usize> for Array2D<T> {
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
&mut self.v[(index) * self.cols..(index + 1) * self.cols]
}
}
impl<T> Mul for &Array2D<T>
where
T: Number,
{
type Output = Array2D<T>;
fn mul(self, rhs: Self) -> Self::Output {
let n = self.rows;
let m = self.cols;
assert_eq!(m, rhs.rows);
let k2 = rhs.cols;
let mut res = Array2D::new(T::ZERO, n, k2);
for i in 0..n {
for j in 0..m {
for k in 0..k2 {
res[i][k] += self[i][j] * rhs[j][k];
}
}
}
res
}
}
impl<T> Array2D<T>
where
T: Number,
{
pub fn pown(&self, pw: usize) -> Self {
assert_eq!(self.rows, self.cols);
let n = self.rows;
if pw == 0 {
Self::new_f(n, n, |r, c| if r == c { T::ONE } else { T::ZERO })
} else if pw == 1 {
self.clone()
} else {
let half = self.pown(pw / 2);
let half2 = &half * ½
if pw & 1 == 0 {
half2
} else {
&half2 * self
}
}
}
}
impl<'a, T> Iterator for Iter<'a, T> {
type Item = &'a T;
fn next(&mut self) -> Option<Self::Item> {
if self.col == self.array.cols {
self.col = 0;
self.row += 1;
}
if self.row >= self.array.rows {
return None;
}
let elem = &self.array[self.row][self.col];
self.col += 1;
Some(elem)
}
}
}
}
pub mod geometry {
pub mod point {
use crate::algo_lib::collections::array_2d::Array2D;
use crate::f;
use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::input::Readable;
use crate::algo_lib::io::output::Output;
use crate::algo_lib::io::output::Writable;
use crate::algo_lib::iters::shifts::Shift;
use crate::algo_lib::misc::num_traits::Number;
use crate::algo_lib::misc::ord_f64::OrdF64;
use std::ops::Add;
use std::ops::AddAssign;
use std::ops::Mul;
use std::ops::Sub;
use std::ops::SubAssign;
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug, Default)]
pub struct PointT<T: Number> {
pub x: T,
pub y: T,
}
impl<T: Ord + Number> Ord for PointT<T> {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.x.cmp(&other.x).then(self.y.cmp(&other.y))
}
}
impl<T: Ord + Number> PartialOrd for PointT<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.cmp(other).into()
}
}
impl<T: Number> PointT<T> {
pub fn new(x: T, y: T) -> Self {
Self { x, y }
}
pub fn dist2(&self, p2: &PointT<T>) -> T {
let dx = self.x - p2.x;
let dy = self.y - p2.y;
dx * dx + dy * dy
}
pub fn side(&self) -> i32 {
if self.y > T::ZERO || (self.y == T::ZERO && self.x >= T::ZERO) {
return 0;
}
1
}
pub fn dist_manh(&self, p2: &PointT<T>) -> T {
let dx = self.x - p2.x;
let dy = self.y - p2.y;
let dx_abs = if dx < T::ZERO { T::ZERO - dx } else { dx };
let dy_abs = if dy < T::ZERO { T::ZERO - dy } else { dy };
dx_abs + dy_abs
}
pub fn angle_to(&self, other: &PointT<T>) -> OrdF64
where
f64: From<T>,
{
let dy = other.y - self.y;
let dx = other.x - self.x;
OrdF64(f64::atan2(dy.into(), dx.into()))
}
pub fn swap_x_y(&self) -> Self {
Self::new(self.y, self.x)
}
pub fn vect_mul(p1: &PointT<T>, p2: &PointT<T>, p3: &PointT<T>) -> T {
(p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x)
}
pub fn scal_mul(p1: &PointT<T>, p2: &PointT<T>, p3: &PointT<T>) -> T {
Self::scal_mul2(&(*p2 - *p1), &(*p3 - *p1))
}
pub fn scal_mul2(p1: &PointT<T>, p2: &PointT<T>) -> T {
p1.x * p2.x + p1.y * p2.y
}
pub fn vect_mul2(p1: &PointT<T>, p2: &PointT<T>) -> T {
p1.x * p2.y - p1.y * p2.x
}
pub fn apply_shift(&self, shift: &Shift) -> Self {
Self {
x: self.x + T::from_i32(shift.dx),
y: self.y + T::from_i32(shift.dy),
}
}
pub fn shift(&self, dx: T, dy: T) -> Self {
Self {
x: self.x + dx,
y: self.y + dy,
}
}
pub fn scale(&self, coef: T) -> Self {
Self {
x: self.x * coef,
y: self.y * coef,
}
}
pub fn index_vec2d<'a, Elem>(&self, arr: &'a [Vec<Elem>]) -> Option<&'a Elem> {
if self.x >= T::ZERO
&& self.x < T::from_i32(arr.len() as i32)
&& self.y >= T::ZERO
&& self.y < T::from_i32(arr[T::to_i32(self.x) as usize].len() as i32)
{
let x = T::to_i32(self.x) as usize;
let y = T::to_i32(self.y) as usize;
Some(&arr[x][y])
} else {
None
}
}
pub fn index_arr2d<'a, Elem>(&self, arr: &'a Array2D<Elem>) -> Option<&'a Elem>
where
Elem: Clone,
{
if self.x >= T::ZERO
&& self.x < T::from_i32(arr.len() as i32)
&& self.y >= T::ZERO
&& self.y < T::from_i32(arr[T::to_i32(self.x) as usize].len() as i32)
{
let x = T::to_i32(self.x) as usize;
let y = T::to_i32(self.y) as usize;
Some(&arr[x][y])
} else {
None
}
}
pub fn rotate_ccw(&self) -> Self {
Self::new(T::ZERO - self.y, self.x)
}
pub const ZERO: PointT<T> = PointT {
x: T::ZERO,
y: T::ZERO,
};
pub fn conv_float(&self) -> PointT<OrdF64> {
PointT::new(OrdF64(self.x.to_f64()), OrdF64(self.y.to_f64()))
}
}
impl<T> Add for PointT<T>
where
T: Number,
{
type Output = Self;
fn add(self, rhs: Self) -> Self::Output {
Self::new(self.x + rhs.x, self.y + rhs.y)
}
}
impl<T> AddAssign for PointT<T>
where
T: Number,
{
fn add_assign(&mut self, rhs: Self) {
self.x += rhs.x;
self.y += rhs.y;
}
}
impl<T> Sub for PointT<T>
where
T: Number,
{
type Output = Self;
fn sub(self, rhs: Self) -> Self::Output {
Self::new(self.x - rhs.x, self.y - rhs.y)
}
}
impl<T> SubAssign for PointT<T>
where
T: Number,
{
fn sub_assign(&mut self, rhs: Self) {
self.x -= rhs.x;
self.y -= rhs.y;
}
}
impl<T> Readable for PointT<T>
where
T: Number + Readable,
{
fn read(input: &mut Input) -> Self {
let x = input.read();
let y = input.read();
Self { x, y }
}
}
impl<T> Writable for PointT<T>
where
T: Number + Writable,
{
fn write(&self, output: &mut Output) {
self.x.write(output);
output.put(b' ');
self.y.write(output);
}
}
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct PointWithIdT<T: Number> {
pub p: PointT<T>,
id: u32,
}
impl<T> PointWithIdT<T>
where
T: Number,
{
pub fn new(p: PointT<T>, id: usize) -> Self {
Self { p, id: id as u32 }
}
pub fn id(&self) -> usize {
self.id as usize
}
}
impl PointWithIdT<OrdF64> {
pub fn dist(&self, other: &Self) -> OrdF64 {
self.p.dist2(&other.p).sqrt()
}
}
impl PointT<OrdF64> {
pub fn rotate_ccw_angle(&self, angle: OrdF64) -> Self {
let cos = f!(angle.0.cos());
let sin = f!(angle.0.sin());
let x = self.x * cos - self.y * sin;
let y = self.y * cos + self.x * sin;
Self { x, y }
}
}
impl Mul<OrdF64> for PointT<OrdF64> {
type Output = PointT<OrdF64>;
fn mul(self, rhs: OrdF64) -> Self::Output {
Self {
x: self.x * rhs,
y: self.y * rhs,
}
}
}
}
}
pub mod io {
pub mod input {
use std::fmt::Debug;
use std::io::Read;
use std::marker::PhantomData;
use std::path::Path;
use std::str::FromStr;
pub struct Input {
input: Box<dyn Read>,
buf: Vec<u8>,
at: usize,
buf_read: usize,
}
macro_rules! read_integer_fun {
($t:ident) => {
#[allow(unused)]
pub fn $t(&mut self) -> $t {
self.read_integer()
}
};
}
impl Input {
const DEFAULT_BUF_SIZE: usize = 4096;
///
/// Using with stdin:
/// ```no_run
/// use algo_lib::io::input::Input;
/// let stdin = std::io::stdin();
/// let input = Input::new(Box::new(stdin));
/// ```
///
/// For read files use ``new_file`` instead.
///
///
pub fn new(input: Box<dyn Read>) -> Self {
Self {
input,
buf: vec![0; Self::DEFAULT_BUF_SIZE],
at: 0,
buf_read: 0,
}
}
pub fn new_stdin() -> Self {
let stdin = std::io::stdin();
Self::new(Box::new(stdin))
}
pub fn new_file<P: AsRef<Path>>(path: P) -> Self {
let file = std::fs::File::open(&path)
.unwrap_or_else(|_| panic!("Can't open file: {:?}", path.as_ref().as_os_str()));
Self::new(Box::new(file))
}
pub fn new_with_size(input: Box<dyn Read>, buf_size: usize) -> Self {
Self {
input,
buf: vec![0; buf_size],
at: 0,
buf_read: 0,
}
}
pub fn new_file_with_size<P: AsRef<Path>>(path: P, buf_size: usize) -> Self {
let file = std::fs::File::open(&path)
.unwrap_or_else(|_| panic!("Can't open file: {:?}", path.as_ref().as_os_str()));
Self::new_with_size(Box::new(file), buf_size)
}
pub fn get(&mut self) -> Option<u8> {
if self.refill_buffer() {
let res = self.buf[self.at];
self.at += 1;
Some(res)
} else {
None
}
}
pub fn peek(&mut self) -> Option<u8> {
if self.refill_buffer() {
Some(self.buf[self.at])
} else {
None
}
}
pub fn skip_whitespace(&mut self) {
while let Some(b) = self.peek() {
if !char::from(b).is_whitespace() {
return;
}
self.get();
}
}
pub fn next_token(&mut self) -> Option<Vec<u8>> {
self.skip_whitespace();
let mut res = Vec::new();
while let Some(c) = self.get() {
if char::from(c).is_whitespace() {
break;
}
res.push(c);
}
if res.is_empty() {
None
} else {
Some(res)
}
}
//noinspection RsSelfConvention
pub fn is_exhausted(&mut self) -> bool {
self.peek().is_none()
}
pub fn has_more_elements(&mut self) -> bool {
!self.is_exhausted()
}
pub fn read<T: Readable>(&mut self) -> T {
T::read(self)
}
pub fn vec<T: Readable>(&mut self, size: usize) -> Vec<T> {
let mut res = Vec::with_capacity(size);
for _ in 0usize..size {
res.push(self.read());
}
res
}
pub fn string_vec(&mut self, size: usize) -> Vec<Vec<u8>> {
let mut res = Vec::with_capacity(size);
for _ in 0usize..size {
res.push(self.string());
}
res
}
pub fn read_line(&mut self) -> String {
let mut res = String::new();
while let Some(c) = self.get() {
if c == b'\n' {
break;
}
if c == b'\r' {
if self.peek() == Some(b'\n') {
self.get();
}
break;
}
res.push(c.into());
}
res
}
#[allow(clippy::should_implement_trait)]
pub fn into_iter<T: Readable>(self) -> InputIterator<T> {
InputIterator {
input: self,
phantom: Default::default(),
}
}
fn read_integer<T: FromStr>(&mut self) -> T
where
<T as FromStr>::Err: Debug,
{
let res = self.read_string();
res.parse::<T>().unwrap()
}
fn read_string(&mut self) -> String {
match self.next_token() {
None => {
panic!("Input exhausted");
}
Some(res) => unsafe { String::from_utf8_unchecked(res) },
}
}
pub fn string_as_string(&mut self) -> String {
self.read_string()
}
pub fn string(&mut self) -> Vec<u8> {
self.read_string().into_bytes()
}
fn read_char(&mut self) -> char {
self.skip_whitespace();
self.get().unwrap().into()
}
fn read_float(&mut self) -> f64 {
self.read_string().parse().unwrap()
}
pub fn f64(&mut self) -> f64 {
self.read_float()
}
fn refill_buffer(&mut self) -> bool {
if self.at == self.buf_read {
self.at = 0;
self.buf_read = self.input.read(&mut self.buf).unwrap();
self.buf_read != 0
} else {
true
}
}
read_integer_fun!(i32);
read_integer_fun!(i64);
read_integer_fun!(i128);
read_integer_fun!(u32);
read_integer_fun!(u64);
read_integer_fun!(usize);
}
pub trait Readable {
fn read(input: &mut Input) -> Self;
}
impl Readable for String {
fn read(input: &mut Input) -> Self {
input.read_string()
}
}
impl Readable for char {
fn read(input: &mut Input) -> Self {
input.read_char()
}
}
impl Readable for f64 {
fn read(input: &mut Input) -> Self {
input.read_string().parse().unwrap()
}
}
impl Readable for f32 {
fn read(input: &mut Input) -> Self {
input.read_string().parse().unwrap()
}
}
impl<T: Readable> Readable for Vec<T> {
fn read(input: &mut Input) -> Self {
let size = input.read();
input.vec(size)
}
}
pub struct InputIterator<T: Readable> {
input: Input,
phantom: PhantomData<T>,
}
impl<T: Readable> Iterator for InputIterator<T> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
self.input.skip_whitespace();
self.input.peek().map(|_| self.input.read())
}
}
macro_rules! read_integer {
($t:ident) => {
impl Readable for $t {
fn read(input: &mut Input) -> Self {
input.read_integer()
}
}
};
}
read_integer!(i8);
read_integer!(i16);
read_integer!(i32);
read_integer!(i64);
read_integer!(i128);
read_integer!(isize);
read_integer!(u8);
read_integer!(u16);
read_integer!(u32);
read_integer!(u64);
read_integer!(u128);
read_integer!(usize);
}
pub mod output {
use std::io::Write;
pub struct Output {
output: Box<dyn Write>,
buf: Vec<u8>,
at: usize,
auto_flush: bool,
}
impl Output {
const DEFAULT_BUF_SIZE: usize = 4096;
pub fn new(output: Box<dyn Write>) -> Self {
Self {
output,
buf: vec![0; Self::DEFAULT_BUF_SIZE],
at: 0,
auto_flush: false,
}
}
pub fn new_stdout() -> Self {
let stdout = std::io::stdout();
Self::new(Box::new(stdout))
}
pub fn new_file(path: impl AsRef<std::path::Path>) -> Self {
let file = std::fs::File::create(path).unwrap();
Self::new(Box::new(file))
}
pub fn new_with_auto_flush(output: Box<dyn Write>) -> Self {
Self {
output,
buf: vec![0; Self::DEFAULT_BUF_SIZE],
at: 0,
auto_flush: true,
}
}
pub fn flush(&mut self) {
if self.at != 0 {
self.output.write_all(&self.buf[..self.at]).unwrap();
self.at = 0;
self.output.flush().expect("Couldn't flush output");
}
}
pub fn print<T: Writable>(&mut self, s: T) {
s.write(self);
}
pub fn println<T: Writable>(&mut self, s: T) {
s.write(self);
self.put(b'\n');
}
pub fn put(&mut self, b: u8) {
self.buf[self.at] = b;
self.at += 1;
if self.at == self.buf.len() {
self.flush();
}
}
pub fn maybe_flush(&mut self) {
if self.auto_flush {
self.flush();
}
}
pub fn print_per_line<T: Writable>(&mut self, arg: &[T]) {
for i in arg {
i.write(self);
self.put(b'\n');
}
}
pub fn print_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
let mut first = true;
for e in iter {
if first {
first = false;
} else {
self.put(b' ');
}
e.write(self);
}
}
pub fn print_iter_ref<'a, T: 'a + Writable, I: Iterator<Item = &'a T>>(&mut self, iter: I) {
let mut first = true;
for e in iter {
if first {
first = false;
} else {
self.put(b' ');
}
e.write(self);
}
}
}
impl Write for Output {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
let mut start = 0usize;
let mut rem = buf.len();
while rem > 0 {
let len = (self.buf.len() - self.at).min(rem);
self.buf[self.at..self.at + len].copy_from_slice(&buf[start..start + len]);
self.at += len;
if self.at == self.buf.len() {
self.flush();
}
start += len;
rem -= len;
}
if self.auto_flush {
self.flush();
}
Ok(buf.len())
}
fn flush(&mut self) -> std::io::Result<()> {
self.flush();
Ok(())
}
}
pub trait Writable {
fn write(&self, output: &mut Output);
}
impl Writable for &str {
fn write(&self, output: &mut Output) {
output.write_all(self.as_bytes()).unwrap();
}
}
impl Writable for String {
fn write(&self, output: &mut Output) {
output.write_all(self.as_bytes()).unwrap();
}
}
impl Writable for char {
fn write(&self, output: &mut Output) {
output.put(*self as u8);
}
}
impl<T: Writable> Writable for [T] {
fn write(&self, output: &mut Output) {
output.print_iter_ref(self.iter());
}
}
impl<T: Writable> Writable for Vec<T> {
fn write(&self, output: &mut Output) {
self[..].write(output);
}
}
macro_rules! write_to_string {
($t:ident) => {
impl Writable for $t {
fn write(&self, output: &mut Output) {
self.to_string().write(output);
}
}
};
}
write_to_string!(u8);
write_to_string!(u16);
write_to_string!(u32);
write_to_string!(u64);
write_to_string!(u128);
write_to_string!(usize);
write_to_string!(i8);
write_to_string!(i16);
write_to_string!(i32);
write_to_string!(i64);
write_to_string!(i128);
write_to_string!(isize);
write_to_string!(f32);
write_to_string!(f64);
impl<T: Writable, U: Writable> Writable for (T, U) {
fn write(&self, output: &mut Output) {
self.0.write(output);
output.put(b' ');
self.1.write(output);
}
}
impl<T: Writable, U: Writable, V: Writable> Writable for (T, U, V) {
fn write(&self, output: &mut Output) {
self.0.write(output);
output.put(b' ');
self.1.write(output);
output.put(b' ');
self.2.write(output);
}
}
}
}
pub mod iters {
pub mod shifts {
#[derive(Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
pub struct Shift {
pub dx: i32,
pub dy: i32,
}
impl Shift {
pub fn rev(&self) -> Self {
Self {
dx: -self.dx,
dy: -self.dy,
}
}
}
// x goes down
// y goes right
pub const SHIFT_DOWN: Shift = Shift { dx: 1, dy: 0 };
pub const SHIFT_UP: Shift = Shift { dx: -1, dy: 0 };
pub const SHIFT_RIGHT: Shift = Shift { dx: 0, dy: 1 };
pub const SHIFT_LEFT: Shift = Shift { dx: 0, dy: -1 };
pub const SHIFTS_4: [Shift; 4] = [SHIFT_DOWN, SHIFT_LEFT, SHIFT_UP, SHIFT_RIGHT];
pub const SHIFTS_8: [Shift; 8] = [
SHIFT_DOWN,
SHIFT_LEFT,
SHIFT_UP,
SHIFT_RIGHT,
Shift { dx: -1, dy: -1 },
Shift { dx: -1, dy: 1 },
Shift { dx: 1, dy: -1 },
Shift { dx: 1, dy: 1 },
];
pub const SHIFTS_9: [Shift; 9] = [
SHIFT_DOWN,
SHIFT_LEFT,
SHIFT_UP,
SHIFT_RIGHT,
Shift { dx: -1, dy: -1 },
Shift { dx: -1, dy: 1 },
Shift { dx: 1, dy: -1 },
Shift { dx: 1, dy: 1 },
Shift { dx: 0, dy: 0 },
];
pub fn shift_by_nswe(c: u8) -> Shift {
match c {
b'S' | b's' => SHIFT_DOWN,
b'N' | b'n' => SHIFT_UP,
b'E' | b'e' => SHIFT_RIGHT,
b'W' | b'w' => SHIFT_LEFT,
_ => panic!("Unexpected direction!"),
}
}
pub fn shift_by_uldr(c: u8) -> Shift {
match c {
b'D' | b'd' => SHIFT_DOWN,
b'U' | b'u' => SHIFT_UP,
b'R' | b'r' => SHIFT_RIGHT,
b'L' | b'l' => SHIFT_LEFT,
_ => panic!("Unexpected direction!"),
}
}
}
}
pub mod misc {
pub mod dbg_macro {
#[macro_export]
#[allow(unused_macros)]
macro_rules! dbg {
($first_val:expr, $($val:expr),+ $(,)?) => {
eprint!("[{}:{}] {} = {:?}",
file!(), line!(), stringify!($first_val), &$first_val);
($(eprint!(", {} = {:?}", stringify!($val), &$val)),+,);
eprintln!();
};
($first_val:expr) => {
eprintln!("[{}:{}] {} = {:?}",
file!(), line!(), stringify!($first_val), &$first_val)
};
}
}
pub mod num_traits {
use std::cmp::Ordering;
use std::fmt::Debug;
use std::ops::Add;
use std::ops::AddAssign;
use std::ops::Div;
use std::ops::DivAssign;
use std::ops::Mul;
use std::ops::MulAssign;
use std::ops::Sub;
use std::ops::SubAssign;
pub trait HasConstants<T> {
const MAX: T;
const MIN: T;
const ZERO: T;
const ONE: T;
const TWO: T;
}
pub trait ConvSimple<T> {
fn from_i32(val: i32) -> T;
fn to_i32(self) -> i32;
fn to_f64(self) -> f64;
}
pub trait Signum {
fn signum(&self) -> i32;
}
pub trait Number:
Copy
+ Add<Output = Self>
+ AddAssign
+ Sub<Output = Self>
+ SubAssign
+ Mul<Output = Self>
+ MulAssign
+ Div<Output = Self>
+ DivAssign
+ PartialOrd
+ PartialEq
+ HasConstants<Self>
+ Default
+ Debug
+ Sized
+ ConvSimple<Self>
{
}
impl<
T: Copy
+ Add<Output = Self>
+ AddAssign
+ Sub<Output = Self>
+ SubAssign
+ Mul<Output = Self>
+ MulAssign
+ Div<Output = Self>
+ DivAssign
+ PartialOrd
+ PartialEq
+ HasConstants<Self>
+ Default
+ Debug
+ Sized
+ ConvSimple<Self>,
> Number for T
{
}
macro_rules! has_constants_impl {
($t: ident) => {
impl HasConstants<$t> for $t {
// TODO: remove `std` for new rust version..
const MAX: $t = std::$t::MAX;
const MIN: $t = std::$t::MIN;
const ZERO: $t = 0;
const ONE: $t = 1;
const TWO: $t = 2;
}
impl ConvSimple<$t> for $t {
fn from_i32(val: i32) -> $t {
val as $t
}
fn to_i32(self) -> i32 {
self as i32
}
fn to_f64(self) -> f64 {
self as f64
}
}
};
}
has_constants_impl!(i32);
has_constants_impl!(i64);
has_constants_impl!(i128);
has_constants_impl!(u32);
has_constants_impl!(u64);
has_constants_impl!(u128);
has_constants_impl!(usize);
has_constants_impl!(u8);
impl ConvSimple<Self> for f64 {
fn from_i32(val: i32) -> Self {
val as f64
}
fn to_i32(self) -> i32 {
self as i32
}
fn to_f64(self) -> f64 {
self
}
}
impl HasConstants<Self> for f64 {
const MAX: Self = Self::MAX;
const MIN: Self = -Self::MAX;
const ZERO: Self = 0.0;
const ONE: Self = 1.0;
const TWO: Self = 2.0;
}
impl<T: Number + Ord> Signum for T {
fn signum(&self) -> i32 {
match self.cmp(&T::ZERO) {
Ordering::Greater => 1,
Ordering::Less => -1,
Ordering::Equal => 0,
}
}
}
}
pub mod ord_f64 {
use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::input::Readable;
use crate::algo_lib::io::output::Output;
use crate::algo_lib::io::output::Writable;
use crate::algo_lib::misc::num_traits::ConvSimple;
use crate::algo_lib::misc::num_traits::HasConstants;
use std::cmp::min;
use std::cmp::Ordering;
use std::f64::consts::PI;
use std::fmt::Debug;
use std::fmt::Display;
use std::fmt::Formatter;
use std::io::Write;
use std::num::ParseFloatError;
use std::ops::Neg;
use std::ops::Rem;
use std::str::FromStr;
#[derive(PartialEq, Copy, Clone, Default)]
pub struct OrdF64(pub f64);
impl OrdF64 {
pub const EPS: Self = Self(1e-9);
pub const SMALL_EPS: Self = Self(1e-4);
pub const PI: Self = Self(PI);
pub fn abs(&self) -> Self {
Self(self.0.abs())
}
pub fn eq_with_eps(&self, other: &Self, eps: Self) -> bool {
let abs_diff = (*self - *other).abs();
abs_diff <= eps || abs_diff <= min(self.abs(), other.abs()) * eps
}
pub fn eq_with_default_eps(&self, other: &Self) -> bool {
self.eq_with_eps(other, Self::EPS)
}
pub fn sqrt(&self) -> Self {
Self(self.0.sqrt())
}
pub fn powf(&self, n: f64) -> Self {
Self(self.0.powf(n))
}
}
impl Eq for OrdF64 {}
impl Ord for OrdF64 {
fn cmp(&self, other: &Self) -> Ordering {
self.partial_cmp(other).unwrap()
}
}
impl PartialOrd for OrdF64 {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.0.partial_cmp(&other.0)
}
}
impl std::ops::Add for OrdF64 {
type Output = Self;
fn add(self, rhs: Self) -> Self::Output {
Self(self.0 + rhs.0)
}
}
impl std::ops::AddAssign for OrdF64 {
fn add_assign(&mut self, rhs: Self) {
self.0 += rhs.0;
}
}
impl std::ops::Sub for OrdF64 {
type Output = Self;
fn sub(self, rhs: Self) -> Self::Output {
Self(self.0 - rhs.0)
}
}
impl std::ops::SubAssign for OrdF64 {
fn sub_assign(&mut self, rhs: Self) {
self.0 -= rhs.0;
}
}
impl std::ops::Mul for OrdF64 {
type Output = Self;
fn mul(self, rhs: Self) -> Self::Output {
Self(self.0 * rhs.0)
}
}
impl std::ops::MulAssign for OrdF64 {
fn mul_assign(&mut self, rhs: Self) {
self.0 *= rhs.0;
}
}
impl std::ops::Div for OrdF64 {
type Output = Self;
fn div(self, rhs: Self) -> Self::Output {
Self(self.0 / rhs.0)
}
}
impl std::ops::DivAssign for OrdF64 {
fn div_assign(&mut self, rhs: Self) {
self.0 /= rhs.0;
}
}
impl Neg for OrdF64 {
type Output = Self;
fn neg(self) -> Self::Output {
Self(-self.0)
}
}
impl Display for OrdF64 {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Display::fmt(&self.0, f)
}
}
impl Debug for OrdF64 {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Debug::fmt(&self.0, f)
}
}
impl Writable for OrdF64 {
fn write(&self, output: &mut Output) {
output.write_fmt(format_args!("{}", self.0)).unwrap();
}
}
impl Readable for OrdF64 {
fn read(input: &mut Input) -> Self {
Self(input.read::<f64>())
}
}
impl HasConstants<Self> for OrdF64 {
const MAX: Self = Self(f64::MAX);
const MIN: Self = Self(-f64::MAX);
const ZERO: Self = Self(0.0);
const ONE: Self = Self(1.0);
const TWO: Self = Self(2.0);
}
impl ConvSimple<Self> for OrdF64 {
fn from_i32(val: i32) -> Self {
Self(val as f64)
}
fn to_i32(self) -> i32 {
self.0 as i32
}
fn to_f64(self) -> f64 {
self.0
}
}
impl FromStr for OrdF64 {
type Err = ParseFloatError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.parse::<f64>() {
Ok(value) => Ok(Self(value)),
Err(error) => Err(error),
}
}
}
impl From<OrdF64> for f64 {
fn from(x: OrdF64) -> Self {
x.0
}
}
impl Rem for OrdF64 {
type Output = Self;
fn rem(self, rhs: Self) -> Self::Output {
Self(self.0 % rhs.0)
}
}
#[macro_export]
macro_rules! f {
($a:expr) => {
OrdF64($a)
};
}
impl From<usize> for OrdF64 {
fn from(x: usize) -> Self {
f!(x as f64)
}
}
impl From<i32> for OrdF64 {
fn from(x: i32) -> Self {
f!(x as f64)
}
}
impl From<i64> for OrdF64 {
fn from(x: i64) -> Self {
f!(x as f64)
}
}
impl From<f64> for OrdF64 {
fn from(x: f64) -> Self {
f!(x)
}
}
}
}
pub mod seg_trees {
pub mod bottom_up_seg_tree {
use std::ops::Range;
use crate::algo_lib::seg_trees::seg_tree_trait::SegTreeNode;
pub struct BottomUpSegTree<Node: SegTreeNode> {
n: usize,
nodes: Vec<Node>,
context: Node::Context,
}
impl<Node: SegTreeNode> BottomUpSegTree<Node> {
pub fn new(start_n: usize, f: impl Fn(usize) -> Node) -> Self
where
Node::Context: Default,
{
let n = start_n.next_power_of_two();
let mut res = Self {
n,
nodes: vec![Node::default(); 2 * n],
context: Default::default(),
};
for i in 0..start_n {
res.nodes[n + i] = f(i);
}
for i in (1..n).rev() {
res.nodes[i] = Node::join_nodes(&res.nodes[2 * i], &res.nodes[2 * i + 1], &res.context);
}
res
}
pub fn update_point(&mut self, pos: usize, v: Node) {
let mut i = pos + self.n;
self.nodes[i] = v;
while i > 1 {
i /= 2;
self.nodes[i] =
Node::join_nodes(&self.nodes[2 * i], &self.nodes[2 * i + 1], &self.context);
}
}
pub fn get(&self, range: Range<usize>) -> Node {
let mut l = range.start + self.n;
let mut r = range.end + self.n;
let mut res_l = Node::default();
let mut res_r = Node::default();
while l < r {
if l & 1 != 0 {
res_l = Node::join_nodes(&res_l, &self.nodes[l], &self.context);
l += 1;
}
if r & 1 != 0 {
r -= 1;
res_r = Node::join_nodes(&self.nodes[r], &res_r, &self.context);
}
l /= 2;
r /= 2;
}
Node::join_nodes(&res_l, &res_r, &self.context)
}
}
}
pub mod seg_tree_trait {
pub trait SegTreeNode: Clone + Default {
fn join_nodes(l: &Self, r: &Self, context: &Self::Context) -> Self;
fn apply_update(node: &mut Self, update: &Self::Update);
fn join_updates(current: &mut Self::Update, add: &Self::Update);
type Update: Clone;
type Context;
}
}
}
}
fn main() {
let input = algo_lib::io::input::Input::new_stdin();
let mut output = algo_lib::io::output::Output::new_stdout();
crate::solution::run(input, output);
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 2148kb
input:
2 1 1 1 3 3 1
output:
1
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 2132kb
input:
3 4 5 5 4 6 7 1 3 8
output:
10.100505063388331
result:
ok found '10.1005051', expected '10.1005051', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 2152kb
input:
2 0 0 1 1000000 1000000 1000000000
output:
1000000000
result:
ok found '1000000000.0000000', expected '1000000000.0000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 1ms
memory: 2280kb
input:
20 328 207 21 365 145 188 347 79 41 374 335 699 288 250 97 32 267 131 296 332 434 2 91 36 139 43 21 26 455 696 57 135 410 14 500 396 255 181 646 103 114 593 309 351 787 207 316 138 440 416 806 413 349 695 413 201 501 455 396 442
output:
6092.442712623782
result:
ok found '6092.4427126', expected '6092.4427126', error '0.0000000'
Test #5:
score: 0
Accepted
time: 1ms
memory: 2164kb
input:
20 38 207 766 202 485 964 257 466 900 205 486 738 166 53 716 61 94 881 252 165 182 63 292 612 225 278 242 224 242 566 381 196 702 56 494 997 268 288 884 379 227 3 357 271 975 55 73 678 260 55 623 399 369 515 116 354 580 404 239 950
output:
11878.257312827458
result:
ok found '11878.2573128', expected '11878.2573128', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 2120kb
input:
20 249 215 320 38 48 229 457 366 56 36 142 186 44 96 935 97 190 143 215 218 123 116 486 291 304 232 463 429 297 29 479 475 97 97 198 405 69 395 121 381 121 926 137 197 972 410 91 218 87 421 737 117 390 144 319 287 170 353 302 754
output:
5573.25589693263
result:
ok found '5573.2558969', expected '5573.2558969', error '0.0000000'
Test #7:
score: 0
Accepted
time: 1ms
memory: 2120kb
input:
20 474 215 66 376 120 6 367 259 211 362 293 34 416 407 554 133 292 894 171 278 871 459 187 674 383 192 980 352 78 899 83 27 684 138 185 709 357 234 359 390 241 40 418 124 161 258 348 462 408 59 851 110 184 668 28 447 761 20 131 367
output:
8510.59561788341
result:
ok found '8510.5956179', expected '8510.5956179', error '0.0000000'
Test #8:
score: 0
Accepted
time: 5926ms
memory: 2384kb
input:
400 979422 264252 76260 922920 334464 58710 87057 798078 39652 602478 649867 49073 388746 161788 44501 727471 373113 28061 944959 505744 22145 191465 164645 49421 102241 771049 65953 44911 762286 34082 112779 537040 98117 688054 585935 53647 391845 931395 55355 788464 698271 91449 984533 409449 8331...
output:
35610300.744289875
result:
ok found '35610300.7442899', expected '35610300.7442899', error '0.0000000'
Test #9:
score: 0
Accepted
time: 5937ms
memory: 2252kb
input:
400 972392 809281 95619 19054 872671 65516 732236 376176 38922 412232 147107 36902 242843 486112 34287 311141 416172 5612 453695 775962 79060 806457 678364 29585 324358 953486 58858 532543 378842 67089 20301 449627 86941 252735 242252 66239 335667 454693 40007 563783 444579 49920 663605 128448 3095 ...
output:
35334006.33097682
result:
ok found '35334006.3309768', expected '35334006.3309768', error '0.0000000'
Test #10:
score: 0
Accepted
time: 6001ms
memory: 2204kb
input:
400 718289 727141 23905 849810 500522 44241 890554 385825 70996 597411 423432 99133 994251 463004 32770 388843 280170 47562 664865 319482 48403 353770 474376 52218 508270 890719 28901 80661 697191 77469 459811 411012 23750 741501 408373 60551 163462 269625 56148 406785 260156 41900 337932 855364 578...
output:
36725958.767186865
result:
ok found '36725958.7671869', expected '36725958.7671869', error '0.0000000'
Test #11:
score: 0
Accepted
time: 5955ms
memory: 2224kb
input:
400 6840 184362 43862 608935 154893 10000000 746897 683314 71237 255918 899062 94342 478185 102216 1923 890855 323689 44654 467417 577805 20 919997 267591 21891 303668 171438 29365 324647 818449 18945 229942 874921 22870 174645 613823 31193 559386 859851 36262 156698 936021 86194 968031 522125 75799...
output:
36590958.86049338
result:
ok found '36590958.8604934', expected '36590958.8604934', error '0.0000000'
Test #12:
score: 0
Accepted
time: 5956ms
memory: 2236kb
input:
400 213928 419916 45837 334919 278535 7824 100882 416988 26147 682280 524709 85794 569137 589867 48913 344075 156956 4813 87794 655931 25690 285467 798402 55113 295984 894760 44628 535011 461670 72400 917862 461662 90830 544780 751382 81071 588022 966874 10000000 872058 880760 39315 216881 626161 22...
output:
46173511.87199231
result:
ok found '46173511.8719923', expected '46173511.8719923', error '0.0000000'
Test #13:
score: 0
Accepted
time: 5939ms
memory: 2252kb
input:
400 937407 829281 77362 837708 843713 34574 77624 684540 68232 786430 452449 38426 486327 341660 86859 964636 122535 12764 699975 284575 84208 806142 721010 10955 464680 787842 37887 395874 727033 70790 59849 84503 90263 557124 876914 45080 168385 390089 16463 6894 13302 8291 380410 621577 47431 992...
output:
45704049.961534254
result:
ok found '45704049.9615343', expected '45704049.9615343', error '0.0000000'
Test #14:
score: 0
Accepted
time: 5948ms
memory: 2228kb
input:
400 769436 473525 91179 925212 211008 73863 393798 496395 71452 241696 745916 92387 519975 24414 32489 867615 821099 81949 644522 605802 2383 237926 379309 38924 389221 50127 90627 201042 315597 28025 314735 422671 18588 616409 476289 21284 397182 521279 80524 190834 918992 35979 405770 829871 41232...
output:
46077961.21213436
result:
ok found '46077961.2121344', expected '46077961.2121344', error '0.0000000'
Test #15:
score: 0
Accepted
time: 5942ms
memory: 2324kb
input:
400 661885 939867 75528 487494 846559 71593 290098 369543 36755 931898 794760 63921 480058 761470 19842 426135 379317 3551 627245 832185 26033 598705 59485 2540 941138 844706 6210 377586 312034 96388 398374 295001 41568 874081 558382 41501 933464 285407 30933 444410 590787 18450 950252 399446 44906 ...
output:
45282826.91919702
result:
ok found '45282826.9191970', expected '45282826.9191970', error '0.0000000'
Test #16:
score: 0
Accepted
time: 5946ms
memory: 2228kb
input:
400 569839 791389 68749 839674 777277 63933 863326 968947 6358 180942 20818 69013 875946 210141 10000000 321824 169791 90333 877709 273385 90285 135978 546433 47341 46246 441438 70141 12053 496729 17675 576117 666429 46856 197452 968179 51530 509363 87403 55583 193224 750277 97047 7722 889000 70489 ...
output:
55534449.24350841
result:
ok found '55534449.2435084', expected '55534449.2435084', error '0.0000000'
Test #17:
score: 0
Accepted
time: 5938ms
memory: 2380kb
input:
400 256630 187847 11194 897382 694378 18835 350562 923633 99933 205851 958234 8647 715754 266300 68929 684673 719293 82041 304184 162766 99040 699035 219131 15513 315331 32273 49150 339042 179271 60962 241294 982748 68635 660080 88445 99207 162427 641286 80190 199541 249437 72499 204956 414509 32836...
output:
56842720.2325438
result:
ok found '56842720.2325438', expected '56842720.2325438', error '0.0000000'
Test #18:
score: 0
Accepted
time: 5942ms
memory: 2252kb
input:
400 891557 241099 10125 316914 425364 32054 657652 448853 28433 475110 718140 83424 425448 596023 65334 128996 426213 53829 813917 692602 28723 693896 817142 8591 16046 375611 26923 184028 990969 58048 498854 915662 79220 77435 469326 15270 775143 697151 56 20169 991072 37373 922109 871304 73982 369...
output:
55025500.341025
result:
ok found '55025500.3410250', expected '55025500.3410250', error '0.0000000'
Test #19:
score: 0
Accepted
time: 5945ms
memory: 2380kb
input:
400 828767 606397 14986 448568 868264 52625 863674 833593 12260 21259 513438 86242 392594 387534 62680 397658 426280 79956 392196 731597 51319 57619 697219 15776 566541 946740 81803 858232 528140 60149 572906 197112 83601 167809 31160 61928 192638 668070 66133 988108 900482 83698 356771 210640 8457 ...
output:
55207053.56148932
result:
ok found '55207053.5614893', expected '55207053.5614893', error '0.0000000'
Test #20:
score: 0
Accepted
time: 5945ms
memory: 2372kb
input:
400 652930 388986 93092 175667 5066 79475 824559 456628 46198 405436 976444 9728 98439 824664 37902 133984 824519 62538 44592 247702 80017 956993 633946 8159 333726 672264 48680 929512 627435 71532 53499 861432 23848 254670 396688 79430 266385 903784 73840 775791 937341 40023 938364 85706 20447 9444...
output:
66199867.48226016
result:
ok found '66199867.4822602', expected '66199867.4822602', error '0.0000000'
Test #21:
score: 0
Accepted
time: 5933ms
memory: 2380kb
input:
400 327433 225448 72419 180629 560500 97932 246413 886763 87194 36579 660354 5583 576311 650681 58242 480636 727717 18522 522922 331330 57537 147188 727126 24744 718669 159276 33254 861143 15648 21698 727055 664167 5898 653626 350031 91550 723519 303309 73005 480206 179059 70729 219329 901693 73987 ...
output:
65993994.75754107
result:
ok found '65993994.7575411', expected '65993994.7575411', error '0.0000000'
Test #22:
score: 0
Accepted
time: 5932ms
memory: 2248kb
input:
400 843902 857131 60014 26310 422832 50339 738436 522415 41915 169028 339593 61310 951478 200194 12415 730116 19247 56519 769040 958693 61076 405104 32233 57682 27255 130563 31613 748330 322448 11181 129992 265273 45001 764569 206047 21608 922901 189481 88493 551608 525267 82388 939239 414554 41669 ...
output:
65858330.02324961
result:
ok found '65858330.0232496', expected '65858330.0232496', error '0.0000000'
Test #23:
score: 0
Accepted
time: 5944ms
memory: 2444kb
input:
400 194443 446536 18933 834480 99470 53935 336848 345002 41697 707312 237775 9771 873005 845270 13646 409784 683252 96882 409557 562036 81118 545905 637225 17578 252812 251471 13038 583122 763953 26440 771214 473649 40389 367234 166473 42042 887080 249162 64664 251593 420947 88496 616004 527987 1948...
output:
65937260.83604751
result:
ok found '65937260.8360475', expected '65937260.8360475', error '0.0000000'
Test #24:
score: 0
Accepted
time: 5964ms
memory: 2376kb
input:
400 12000 15000 680 11000 1000 591 17000 5000 519 8000 11000 858 13000 10000 311 8000 18000 395 14000 9000 877 13000 3000 287 12000 1000 941 4000 16000 984 14000 18000 649 16000 11000 658 11000 3000 384 15000 17000 4 9000 9000 54 14000 17000 792 4000 1000 663 8000 1000 264 15000 12000 266 4000 10000...
output:
122036
result:
ok found '122036.0000000', expected '122036.0000000', error '0.0000000'
Test #25:
score: 0
Accepted
time: 5956ms
memory: 2240kb
input:
400 4000 8000 938 6000 15000 810 3000 12000 418 11000 10000 371 3000 0 827 11000 8000 698 15000 15000 472 3000 6000 882 14000 20000 102 7000 12000 316 16000 8000 670 1000 12000 762 8000 4000 870 14000 6000 444 5000 17000 738 17000 20000 805 13000 15000 783 6000 5000 265 3000 13000 250 13000 1000 78 ...
output:
128699
result:
ok found '128699.0000000', expected '128699.0000000', error '0.0000000'
Test #26:
score: 0
Accepted
time: 5336ms
memory: 2324kb
input:
393 501977 499949 1064 501419 499972 9173 500849 499948 9603 500589 499952 6032 504175 499982 4549 501116 499970 1533 500453 499968 982 500011 499934 6882 501220 499934 8645 504473 499950 2317 503158 499959 1540 503053 499979 5786 501377 499989 7154 500421 500000 3273 500014 499937 9631 500223 49998...
output:
2073525
result:
ok found '2073525.0000000', expected '2073525.0000000', error '0.0000000'
Test #27:
score: 0
Accepted
time: 5129ms
memory: 2372kb
input:
396 498773 499704 5151 498639 499979 6010 498813 500339 5372 499052 500511 5691 499749 499597 927 498679 500163 6899 499191 500563 6999 499988 500081 2093 498654 500099 3267 499856 499695 6590 499344 499422 3869 499293 499422 4747 498637 500001 4148 499229 500571 932 499980 500109 5609 499505 500545...
output:
2064044.0784045083
result:
ok found '2064044.0784045', expected '2064044.0784045', error '0.0000000'
Test #28:
score: -100
Time Limit Exceeded
input:
400 40303 40303 1453 390251 390251 1312 253614 253614 1546 139586 139586 1412 24575 24575 941 183821 183821 1502 236903 236903 1209 231988 231988 979 384353 384353 1162 146467 146467 1170 112062 112062 1684 355846 355846 1593 230022 230022 1513 302764 302764 1552 87487 87487 1599 28507 28507 997 331...