Submission #70778582


Source Code Expand

#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]
#![allow(unused_macros)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

type Vec2<T> = Vec<Vec<T>>;
type Vec3<T> = Vec<Vec<Vec<T>>>;
#[rustfmt::skip]
macro_rules ! max { ( $x : expr ) => ( $x ) ; ( $x : expr , $ ( $xs : expr ) ,+ ) => { {  std :: cmp :: max ( $x , max! ( $ ( $xs ) ,+ ) ) } } ; }
#[rustfmt::skip]
macro_rules ! min { ( $x : expr ) => ( $x ) ; ( $x : expr , $ ( $xs : expr ) ,+ ) => { {  std :: cmp :: min ( $x , min! ( $ ( $xs ) ,+ ) ) } } ; }
#[rustfmt::skip]
macro_rules! chmin {    ($a:expr, $($b:expr),+) => {{        let d = min!($($b),+);        if $a > d {            $a = d;            true        } else {            false        }    }}; }

#[rustfmt::skip]
macro_rules! chmax {    ($a:expr, $($b:expr),+) => {{        let d = max!($($b),+);        if $a < d {            $a = d;            true        } else {            false        }    }};}

#[rustfmt::skip]
macro_rules! chadd {    ($a:expr, $b:expr) => {{        $a = $a + $b;    }};}
#[rustfmt::skip]
macro_rules! chsub {    ($a:expr, $b:expr) => {{        $a = $a - $b;    }};}
#[rustfmt::skip]
macro_rules! chmul {    ($a:expr, $b:expr) => {{        $a = $a * $b;    }};}

#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

macro_rules! multivec {
    ($a:expr;$b:expr) => {
        vec![$a; $b]
    };
    ($a:expr;$b:expr;$($c:expr);+) => {
        multivec![vec![$a;$b];$($c);+]
    };
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Rem, Sub};

fn echoNoReturn() {
    echo!("No");
    std::process::exit(0);
}
fn echoYesReturn() {
    echo!("Yes");
    std::process::exit(0);
}

fn echoNo() {
    echo!("No");
}
fn echoYes() {
    echo!("Yes");
}

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

fn sin(a: f64) -> f64 {
    a.sin()
}
fn cos(a: f64) -> f64 {
    a.cos()
}
trait ToNum {
    fn toNum(&self) -> Vec<usize>;
}
impl ToNum for Vec<char> {
    fn toNum(&self) -> Vec<usize> {
        if self[0].is_ascii_digit() {
            self.iter().map(|x| x.toNumIndex()).toVec()
        } else {
            self.iter().map(|x| x.toAlphabetIndex()).toVec()
        }
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}
trait PrimeNumber:
    Copy
    + Ord
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self>
    + Rem<Output = Self>
{
    fn is_odd(self) -> bool;
    fn is_even(self) -> bool;
    fn pow(self, exp: u32) -> Self;
}

macro_rules! impl_prim_int(($($ty:ty),*) => {
    $(
        impl PrimeNumber for $ty {
            fn pow(self, exp: u32) -> Self {
                self.pow(exp)
            }
            fn is_odd(self)->bool{
                self & 1==1
            }

            fn is_even(self)->bool{
                self & 1==0
            }
        }
    )*
});

trait SafeRangeContain {
    fn safe_contains(&self, x: i64) -> bool;
}

impl SafeRangeContain for std::ops::Range<usize> {
    fn safe_contains(&self, x: i64) -> bool {
        if x < 0 {
            return false;
        }
        return self.contains(&(x as usize));
    }
}

impl_prim_int!(
    u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize
);
trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

use itertools_num::ItertoolsNum as _;
use superslice::*;

fn main() {
    input! {
       N: usize,
       A:[(usize,i64,i64);N],
    }

    let mut ans = 0;

    let mut dp = vec![i64::MIN / 10; 500 * N + 10];
    dp[0] = 0;
    let mut sum = 0;

    for i in 0..N {
        let mut pre = vec![i64::MIN / 10; 500 * N + 10];
        std::mem::swap(&mut dp, &mut pre);
        let (w, h, b) = A[i];
        for j in 0..=500 * N {
            if j + w <= 500 * N {
                chmax!(dp[j + w], pre[j] + h);
            }
            chmax!(dp[j], pre[j] + b);
        }
        sum += w;
    }
    for i in 0..=sum {
        let b = sum - i;
        if i <= b {
            chmax!(ans, dp[i]);
        }
    }
    echo!(ans);
}

Submission Info

Submission Time
Task D - Robot Customize
User bqn
Language Rust (rustc 1.89.0)
Score 400
Code Size 5867 Byte
Status AC
Exec Time 194 ms
Memory 5928 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 54
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 01_random_45.txt, 01_random_46.txt, 01_random_47.txt, 01_random_48.txt, 01_random_49.txt, 01_random_50.txt, 01_random_51.txt, 01_random_52.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 1988 KiB
00_sample_01.txt AC 0 ms 2000 KiB
00_sample_02.txt AC 0 ms 2000 KiB
00_sample_03.txt AC 1 ms 2100 KiB
01_random_03.txt AC 192 ms 5808 KiB
01_random_04.txt AC 192 ms 5712 KiB
01_random_05.txt AC 193 ms 5812 KiB
01_random_06.txt AC 193 ms 5788 KiB
01_random_07.txt AC 192 ms 5844 KiB
01_random_08.txt AC 193 ms 5676 KiB
01_random_09.txt AC 193 ms 5820 KiB
01_random_10.txt AC 193 ms 5864 KiB
01_random_11.txt AC 192 ms 5680 KiB
01_random_12.txt AC 113 ms 4912 KiB
01_random_13.txt AC 41 ms 3664 KiB
01_random_14.txt AC 34 ms 3552 KiB
01_random_15.txt AC 67 ms 4244 KiB
01_random_16.txt AC 23 ms 3244 KiB
01_random_17.txt AC 194 ms 5848 KiB
01_random_18.txt AC 193 ms 5928 KiB
01_random_19.txt AC 194 ms 5876 KiB
01_random_20.txt AC 194 ms 5824 KiB
01_random_21.txt AC 192 ms 5724 KiB
01_random_22.txt AC 35 ms 3500 KiB
01_random_23.txt AC 1 ms 2236 KiB
01_random_24.txt AC 0 ms 2016 KiB
01_random_25.txt AC 194 ms 5888 KiB
01_random_26.txt AC 194 ms 5756 KiB
01_random_27.txt AC 194 ms 5712 KiB
01_random_28.txt AC 194 ms 5824 KiB
01_random_29.txt AC 194 ms 5716 KiB
01_random_30.txt AC 191 ms 5696 KiB
01_random_31.txt AC 135 ms 5204 KiB
01_random_32.txt AC 62 ms 4036 KiB
01_random_33.txt AC 0 ms 2008 KiB
01_random_34.txt AC 0 ms 2020 KiB
01_random_35.txt AC 193 ms 5832 KiB
01_random_36.txt AC 192 ms 5824 KiB
01_random_37.txt AC 193 ms 5820 KiB
01_random_38.txt AC 193 ms 5828 KiB
01_random_39.txt AC 193 ms 5820 KiB
01_random_40.txt AC 193 ms 5716 KiB
01_random_41.txt AC 193 ms 5780 KiB
01_random_42.txt AC 193 ms 5764 KiB
01_random_43.txt AC 69 ms 4236 KiB
01_random_44.txt AC 160 ms 5292 KiB
01_random_45.txt AC 131 ms 5148 KiB
01_random_46.txt AC 8 ms 2588 KiB
01_random_47.txt AC 48 ms 3744 KiB
01_random_48.txt AC 190 ms 5824 KiB
01_random_49.txt AC 190 ms 5868 KiB
01_random_50.txt AC 190 ms 5784 KiB
01_random_51.txt AC 3 ms 2200 KiB
01_random_52.txt AC 30 ms 3468 KiB