結果
問題 | No.1389 Clumsy Calculation |
ユーザー |
![]() |
提出日時 | 2021-02-12 21:29:14 |
言語 | Rust (1.83.0 + proconio) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,744 bytes |
コンパイル時間 | 13,593 ms |
コンパイル使用メモリ | 396,108 KB |
最終ジャッジ日時 | 2024-11-15 00:03:18 |
合計ジャッジ時間 | 14,752 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
error: format argument must be a string literal --> src/main.rs:18:34 | 18 | Err(e) => panic!(e), | ^ | help: you might be missing a string literal to format with | 18 | Err(e) => panic!("{}", e), | +++++ error: could not compile `main` (bin "main") due to 1 previous error
ソースコード
mod io {#[macro_export]macro_rules! scan {($r:expr, [$t:tt; $n:expr]) => ((0..$n).map(|_| scan!($r, $t)).collect::<Vec<_>>());($r:expr, ($($t:tt),*)) => (($(scan!($r, $t)),*));($r:expr, [u8]) => (io::scan($r).into_bytes());($r:expr, $t:ty) => (io::scan($r).parse::<$t>().unwrap());}use std::io::{BufRead, ErrorKind};pub fn scan<R: BufRead>(r: &mut R) -> String {let mut res = Vec::new();loop {let buf = match r.fill_buf() {Ok(buf) => buf,Err(e) if e.kind() == ErrorKind::Interrupted => continue,Err(e) => panic!(e),};let (done, used) = match buf.iter().position(u8::is_ascii_whitespace) {Some(i) => {res.extend_from_slice(&buf[..i]);(res.len() > 0, i + 1)}None => {res.extend_from_slice(buf);(false, buf.len())}};r.consume(used);if done || used == 0 {return res.into_iter().map(char::from).collect();}}}}use std::io::{BufRead, Write};fn run<R: BufRead, W: Write>(reader: &mut R, writer: &mut W) {let (n, x) = scan!(reader, (usize, usize));let s = scan!(reader, [usize; n]);let sum = s.iter().sum::<usize>();let ans = sum - (n - 1) * x;writeln!(writer, "{}", ans).ok();}fn main() {let (stdin, stdout) = (std::io::stdin(), std::io::stdout());let mut reader = std::io::BufReader::new(stdin.lock());let mut writer = std::io::BufWriter::new(stdout.lock());run(&mut reader, &mut writer);}