結果
| 問題 |
No.9 モンスターのレベル上げ
|
| ユーザー |
tsubu_taiyaki
|
| 提出日時 | 2017-02-06 06:07:45 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,040 bytes |
| コンパイル時間 | 12,599 ms |
| コンパイル使用メモリ | 378,700 KB |
| 最終ジャッジ日時 | 2024-11-14 19:57:54 |
| 合計ジャッジ時間 | 13,268 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
error[E0782]: trait objects must include the `dyn` keyword
--> src/main.rs:10:21
|
10 | tokens: &'a mut Iterator<Item = String>,
| ^^^^^^^^^^^^^^^^^^^^^^^
|
help: add `dyn` keyword before this trait
|
10 | tokens: &'a mut dyn Iterator<Item = String>,
| +++
error[E0782]: trait objects must include the `dyn` keyword
--> src/main.rs:14:23
|
14 | fn new(i: &'a mut Iterator<Item = String>) -> Self {
| ^^^^^^^^^^^^^^^^^^^^^^^
|
help: add `dyn` keyword before this trait
|
14 | fn new(i: &'a mut dyn Iterator<Item = String>) -> Self {
| +++
For more information about this error, try `rustc --explain E0782`.
error: could not compile `main` (bin "main") due to 2 previous errors
ソースコード
#![allow(unused_imports)]
use std::io::{self, BufRead};
use std::str::FromStr;
use std::collections::*;
use std::cmp::*;
#[allow(dead_code)]
struct Parser<'a> {
tokens: &'a mut Iterator<Item = String>,
}
#[allow(dead_code)]
impl<'a> Parser<'a> {
fn new(i: &'a mut Iterator<Item = String>) -> Self {
Parser {tokens: i}
}
fn take<T: FromStr>(&mut self) -> T {
match self.tokens.next().expect("empty iterator").parse() {
Ok(x) => x,
Err(_) => panic!()
}
}
fn take_some<T: FromStr>(&mut self, n: usize) -> Vec<T> {
self.tokens.take(n).map(|s| match s.parse() { Ok(x) => x, Err(_) => panic!() } ).collect()
}
}
//sieve[k] is true if k is a prime
//[0, n)
#[allow(dead_code)]
fn sieve_of_eratosthenes(n: u64) -> Vec<bool> {
let mut v = vec![true; n as usize];
v[0] = false;
v[1] = false;
for i in 2..n {
if !v[i as usize] {
continue;
}
let mut j = 2*i;
while j < n {
v[j as usize] = false;
j += i;
}
}
v
}
fn main() {
let stdin = io::stdin();
let mut tokens = stdin.lock().lines().filter_map(|x| x.ok()).flat_map(|x| x.split_whitespace().map(|s| s.to_owned()).collect::<Vec<String>>());
let mut parser = Parser::new(&mut tokens);
let n: usize = parser.take();
let a: Vec<i32> = parser.take_some(n);
let b: Vec<i32> = parser.take_some(n);
let a: BTreeSet<_> = a.into_iter().zip(0..n).map(|x| (x.0, 0, x.1)).collect();
let b: Vec<i32> = b.into_iter().map(|x| x/2).collect();
let mut ans = n;
for i in 0..n {
let mut ai = a.clone();
for j in 0..n {
let idx = (i+j) % n;
let x = (*ai.iter().nth(0).unwrap()).clone();
ai.remove(&x);
ai.insert((x.0 + b[idx], x.1+1, x.2));
}
let mut ansi = 0;
for ite in ai.into_iter() {
ansi = max(ansi, ite.1);
}
ans = min(ans, ansi);
}
println!("{}", ans);
}
tsubu_taiyaki