結果
| 問題 | No.1860 Magnets |
| コンテスト | |
| ユーザー |
ixTL255
|
| 提出日時 | 2023-01-02 18:26:06 |
| 言語 | Rust (1.97.1 + proconio + num + itertools + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 0 ms / 2,000 ms |
| + 868µs | |
| コード長 | 326 bytes |
| 記録 | |
| コンパイル時間 | 647 ms |
| コンパイル使用メモリ | 189,976 KB |
| 実行使用メモリ | 9,904 KB |
| 最終ジャッジ日時 | 2026-09-30 14:23:04 |
| 合計ジャッジ時間 | 2,921 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 28 |
コンパイルメッセージ
warning: variable does not need to be mutable
--> src/main.rs:4:6
|
4 | let mut ab: Vec<i64> = ab.trim().split_whitespace()
| ----^^
| |
| help: remove this `mut`
|
= note: `#[warn(unused_mut)]` (part of `#[warn(unused)]`) on by default
warning: value assigned to `ans` is never read
--> src/main.rs:8:16
|
8 | let mut ans = 0i64;
| ^^^^ this value is reassigned later and never used
9 | if a == b { ans = a + b; }
10 | else { ans = a + b + (a - b).abs() - 1; }
| ------------------------------- `ans` is overwritten here before the previous value is read
|
= note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default
ソースコード
fn main() {
let mut ab = String::new();
std::io::stdin().read_line(&mut ab).ok();
let mut ab: Vec<i64> = ab.trim().split_whitespace()
.map(|e| e.parse().unwrap()).collect();
let a = ab[0];
let b = ab[1];
let mut ans = 0i64;
if a == b { ans = a + b; }
else { ans = a + b + (a - b).abs() - 1; }
println!("{}", ans);
}
ixTL255