結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー ikomaikoma
提出日時 2024-04-19 23:14:20
言語 Rust
(1.77.0)
結果
AC  
実行時間 823 ms / 5,000 ms
コード長 1,852 bytes
コンパイル時間 1,833 ms
コンパイル使用メモリ 183,656 KB
実行使用メモリ 18,552 KB
最終ジャッジ日時 2024-04-19 23:15:02
合計ジャッジ時間 16,040 ms
ジャッジサーバーID
(参考情報)
judge5 / judge6
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 0 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 0 ms
6,944 KB
testcase_13 AC 0 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 0 ms
6,944 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 507 ms
16,040 KB
testcase_18 AC 548 ms
16,208 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 744 ms
18,384 KB
testcase_23 AC 744 ms
18,356 KB
testcase_24 AC 738 ms
18,416 KB
testcase_25 AC 791 ms
18,552 KB
testcase_26 AC 751 ms
18,416 KB
testcase_27 AC 805 ms
17,652 KB
testcase_28 AC 746 ms
18,260 KB
testcase_29 AC 823 ms
18,064 KB
testcase_30 AC 685 ms
17,124 KB
testcase_31 AC 732 ms
18,272 KB
testcase_32 AC 672 ms
17,172 KB
testcase_33 AC 448 ms
13,260 KB
testcase_34 AC 559 ms
15,616 KB
testcase_35 AC 299 ms
9,600 KB
testcase_36 AC 326 ms
10,240 KB
testcase_37 AC 475 ms
13,920 KB
testcase_38 AC 463 ms
13,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(unused_imports, dead_code, unused_macros, unused_variables, non_snake_case, unused_parens)]
use proconio::{input,marker::{Bytes, Chars, Usize1,Isize1}};
use std::cmp::*;
use std::mem::swap;
use std::collections::*;

const MOD:u64 = 998244353;
const INF:i64 = 0x3fff_ffff_ffff_ffff;

macro_rules! min {($a:expr $(,)*) => {{$a}};($a:expr, $b:expr $(,)*) => {{std::cmp::min($a, $b)}};($a:expr, $($rest:expr),+ $(,)*) => {{std::cmp::min($a, min!($($rest),+))}};}
macro_rules! max {($a:expr $(,)*) => {{$a}};($a:expr, $b:expr $(,)*) => {{std::cmp::max($a, $b)}};($a:expr, $($rest:expr),+ $(,)*) => {{std::cmp::max($a, max!($($rest),+))}};}
macro_rules! chmin {($base:expr, $($cmps:expr),+ $(,)*) => {{let cmp_min = min!($($cmps),+);if $base > cmp_min {$base = cmp_min;true} else {false}}};}
macro_rules! chmax {($base:expr, $($cmps:expr),+ $(,)*) => {{let cmp_max = max!($($cmps),+);if $base < cmp_max {$base = cmp_max;true} else {false}}};}
macro_rules! mulvec {($x:expr; $s:expr) => {vec![$x; $s]};($x:expr; $s0:expr; $( $s:expr );+) => {mulvec![vec![$x; $s0]; $( $s );+ ]};}
macro_rules! outputln {($var:expr)=>{println!("{}",$var)};($var:expr,$($vars:expr),+)=>{print!("{} ",$var);outputln!($($vars),+);};}
macro_rules! debug {($($a:expr),* $(,)*) => {eprintln!(concat!($("| ",stringify!($a), "={:?} "),*, "|"),$(&$a),*);};}

fn solve() {
	input! {
		N:usize,
		mut A:[String;N],
	}
	let mut pow10 = vec![1];
	for _ in 0..20 {
		pow10.push(pow10[pow10.len()-1]*10%MOD);
	}
	A.sort_by(|a,b| (a.clone()+b).partial_cmp(&(b.clone()+a)).unwrap());
	let mut ans = 0;
	for a in A {
		let n = a.len();
		let a:u64 = a.parse().unwrap();
		ans *= pow10[n];
		ans += a;
		ans %= MOD;
	}
	outputln!(ans);

}

fn main() {
    std::thread::Builder::new()
        .stack_size(128 * 1024 * 1024)
        .spawn(|| solve()).unwrap()
        .join().unwrap();
}
0