提出 #59307203


ソースコード 拡げる

#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(clippy::needless_range_loop)]
#![allow(clippy::comparison_chain)]
#![allow(clippy::nonminimal_bool)]
#![allow(clippy::neg_multiply)]
use ac_library::*;
use amplify::confinement::Collection;
use itertools::{CombinationsWithReplacement, Itertools};
use lazy_static::lazy_static;
use libm::{ceil, log};
use num::{integer::Roots, traits::Pow, ToPrimitive};
use num_bigint::BigInt;
use num_integer::{div_ceil, Integer};
use proconio::marker::{Chars, Usize1};
use proconio::{input, source::line::LineSource};
use std::collections::{BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::From;
use std::f64::consts::PI;
use std::hash::Hash;
use std::mem::swap;
use std::ops::Index;
use std::ops::Mul;
use std::{io::*, string};

fn solve() {
    #[rustfmt::skip]
    input! {
        N:usize,
         A:[usize; N - 1],
         B:[usize; N - 2]
    }
    let mut dp = vec![1 << 60; N];
    dp[0] = 0;
    for i in 0..N {
        if i >= 1 {
            dp[i] = dp[i].min(dp[i - 1] + A[i - 1]);
        }
        if i >= 2 {
            dp[i] = dp[i].min(dp[i - 2] + B[i - 2]);
        }
    }
    let mut ans = vec![];
    let mut now = N - 1;
    while now > 0 {
        if now >= 1 && dp[now - 1] + A[now - 1] == dp[now] {
            ans.push(now + 1);
            now = now - 1;
        } else if now >= 2 && dp[now - 2] + B[now - 2] == dp[now] {
            ans.push(now + 1);
            now = now - 2;
        }
    }
    ans.push(1);
    ans.reverse();
    println!("{}", ans.len());
    println!("{}", ans.iter().join(" "));
}

fn main() {
    // input! {N:usize}
    // for _ in 0..N {
    //     solve();
    // }
    solve();
}

提出情報

提出日時
問題 A17 - Dungeon 2
ユーザ rakka
言語 Rust (rustc 1.70.0)
得点 1000
コード長 1802 Byte
結果 AC
実行時間 7 ms
メモリ 6216 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 1000 / 1000
結果
AC × 2
AC × 17
セット名 テストケース
Sample sample_01.txt, sample_02.txt
All large_01.txt, large_02.txt, large_03.txt, max_01.txt, max_02.txt, sample_01.txt, sample_02.txt, small_01.txt, small_02.txt, small_03.txt, small_04.txt, small_05.txt, small_06.txt, small_07.txt, small_08.txt, small_09.txt, small_10.txt
ケース名 結果 実行時間 メモリ
large_01.txt AC 7 ms 5772 KiB
large_02.txt AC 6 ms 5344 KiB
large_03.txt AC 5 ms 4224 KiB
max_01.txt AC 7 ms 6216 KiB
max_02.txt AC 6 ms 5860 KiB
sample_01.txt AC 1 ms 1992 KiB
sample_02.txt AC 1 ms 1812 KiB
small_01.txt AC 1 ms 1900 KiB
small_02.txt AC 1 ms 1992 KiB
small_03.txt AC 0 ms 2016 KiB
small_04.txt AC 1 ms 1900 KiB
small_05.txt AC 1 ms 2084 KiB
small_06.txt AC 1 ms 1992 KiB
small_07.txt AC 1 ms 1940 KiB
small_08.txt AC 1 ms 1996 KiB
small_09.txt AC 1 ms 1940 KiB
small_10.txt AC 1 ms 2012 KiB