結果
| 問題 |
No.365 ジェンガソート
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-05-25 07:14:34 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 722 bytes |
| コンパイル時間 | 13,185 ms |
| コンパイル使用メモリ | 384,224 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-05-25 07:15:02 |
| 合計ジャッジ時間 | 15,309 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 41 |
コンパイルメッセージ
warning: unnecessary parentheses around `if` condition
--> src/main.rs:23:12
|
23 | if (idx == 0) {
| ^ ^
|
= note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
|
23 - if (idx == 0) {
23 + if idx == 0 {
|
warning: unnecessary parentheses around `if` condition
--> src/main.rs:24:16
|
24 | if (a[idx] != n-cnt) {
| ^ ^
|
help: remove these parentheses
|
24 - if (a[idx] != n-cnt) {
24 + if a[idx] != n-cnt {
|
warning: unnecessary parentheses around `if` condition
--> src/main.rs:29:12
|
29 | if (a[idx] == n-cnt) {
| ^ ^
|
help: remove these parentheses
|
29 - if (a[idx] == n-cnt) {
29 + if a[idx] == n-cnt {
|
ソースコード
/*
* Author: srtry
* Created: 2025-05-25T06:50:42+09:00
* Coding: utf-8-unix
*/
use proconio::input;
use std::io::{stdout,Write,BufWriter};
fn main() {
input!{
n:usize,
mut a:[usize;n]
}
let out = stdout();
let mut out = BufWriter::new(out.lock());
let mut ans:usize = 0;
let mut cnt:usize = 0;
let mut idx:usize = n-1;
loop {
if (idx == 0) {
if (a[idx] != n-cnt) {
ans += 1;
}
break;
}
if (a[idx] == n-cnt) {
cnt += 1;
idx -= 1;
} else {
ans += 1;
idx -= 1;
}
}
write!(out, "{}", ans).unwrap();
}