31 lines
723 B
Rust
31 lines
723 B
Rust
use std::io::{read_to_string, stdin};
|
|
|
|
fn main() {
|
|
let temp = read_to_string(stdin()).unwrap();
|
|
let mut iter = temp
|
|
.split_ascii_whitespace()
|
|
.map(|x| x.parse::<usize>().unwrap());
|
|
|
|
let n = iter.next().unwrap();
|
|
|
|
let grid: Vec<Vec<usize>> = (0..n)
|
|
.map(|_| (0..n).map(|_| iter.next().unwrap()).collect::<Vec<_>>())
|
|
.collect();
|
|
|
|
let mut maxima = 0;
|
|
for i in 1..n - 1 {
|
|
for j in 1..n - 1 {
|
|
let mut s = 0;
|
|
for ii in 0..3 {
|
|
for jj in 0..3 {
|
|
s += grid[i + ii - 1][j + jj - 1];
|
|
}
|
|
}
|
|
|
|
maxima = std::cmp::max(maxima, s);
|
|
}
|
|
}
|
|
|
|
println!("{}", maxima);
|
|
}
|