Submission #2125254
Source Code Expand
fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> { (0..n).map(|_| read_vec()).collect() } fn main(){ let n:u32 = read(); let mut s: Vec<Vec<i32>> = read_vec2(n); let mut p: Vec<Vec<i32>> = read_vec2(n); // let ans: Vec<(&Vec<i32>,&Vec<i32>)>= s.iter().zip(p.iter()).collect(); let mut v: Vec<&i32>= Vec::new(); let mut ans = 0; // s.iter().zip(p.iter()) // .map(|x| v.push(x.1.split_at((x.0.iter().sum::<i32>() + 1) as usize) // .0.iter().max().unwrap())); for i in 0..n { let sub = p[i as usize].split_at((s[i as usize].iter().sum::<i32>() + 1) as usize).0; if sub.iter().max().unwrap() == &0 && v.contains(&&0) { v.push(sub.iter().filter(|x| x != &&0).max().unwrap()); ans += sub.iter().filter(|x| x != &&0).max().unwrap(); } else { v.push(sub.iter().max().unwrap()); ans += sub.iter().max().unwrap(); } } print!("{:?}",ans); }
Submission Info
Submission Time | |
---|---|
Task | C - Shopping Street |
User | elaina |
Language | Rust (1.15.1) |
Score | 0 |
Code Size | 1343 Byte |
Status | CE |
Compile Error
error[E0277]: the trait bound `{integer}: std::ops::AddAssign<&i32>` is not satisfied --> ./Main.rs:33:13 | 33 | ans += sub.iter().filter(|x| x != &&0).max().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::AddAssign<&i32>` is not implemented for `{integer}` | = help: the following implementations were found: = help: <u32 as std::ops::AddAssign> = help: <std::num::Wrapping<usize> as std::ops::AddAssign> = help: <std::num::Wrapping<u8> as std::ops::AddAssign> = help: <std::num::Wrapping<u16> as std::ops::AddAssign> = help: and 24 others error[E0277]: the trait bound `{integer}: std::ops::AddAssign<&i32>` is not satisfied --> ./Main.rs:36:13 | 36 | ans += sub.iter().max().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::AddAssign<&i32>` is not implemented for `{integer}` | = help: the following implementations were found: = help: <u32 as std::ops::AddA...