結果

問題 No.1046 Fruits Rush
ユーザー ixTL255ixTL255
提出日時 2023-01-01 01:43:01
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 485 bytes
コンパイル時間 1,328 ms
コンパイル使用メモリ 146,144 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-17 22:58:53
合計ジャッジ時間 2,372 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable does not need to be mutable
 --> Main.rs:6:6
  |
6 |     let mut nk: Vec<usize> = s1.trim().split_whitespace()
  |         ----^^
  |         |
  |         help: remove this `mut`
  |
  = note: `#[warn(unused_mut)]` on by default

warning: 1 warning emitted

ソースコード

diff #

use std::io;

fn main() {
	let mut s1 = String::new();
	io::stdin().read_line(&mut s1).ok();
	let mut nk: Vec<usize> = s1.trim().split_whitespace()
		.map(|e| e.parse().ok().unwrap()).collect();
	let mut s2 = String::new();
	io::stdin().read_line(&mut s2).ok();
	let mut a: Vec<i32> = s2.trim().split_whitespace()
		.map(|e| e.parse().ok().unwrap()).collect();
	a.sort();
	a.reverse();
	let mut ans = 0i32;
	for i in 0..nk[1] {
		if a[i] > 0 { ans += a[i]; }
	}
	println!("{}", ans);
}
0