Submission #1371387
Source Code Expand
use std::io; use std::collections::VecDeque; fn main() { let mut input = Input::new(); let n: usize = input.next(); let x: i64 = input.next(); let mut a: Vec<i64> = vec![0;n]; for i in 0..n { a[i] = input.next(); } let mut t: i64 = 0; let mut r: i64 = 0; for i in 0..n { let mut m = i64::max_value(); let mut b = 0; let mut v = 0; for j in 0..n { let k = if i < j { (i + n - j) } else { (i - j) } as i64; if m > k * x + a[j] { m = k * x + a[j]; b = j; v = k; } } t += a[b]; if r < v { r = v; } } println!("{}", t + r * x); } struct Input { queue: VecDeque<String>, } impl Input { fn new() -> Input { Input { queue: VecDeque::new() } } fn next<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug { if self.queue.is_empty() { let mut line = String::new(); let _ = io::stdin().read_line(&mut line); for x in line.split_whitespace() { self.queue.push_back(String::from(x)); } } return self.queue.pop_front().unwrap().parse::<T>().unwrap(); } }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Slimes |
User | hoshi524 |
Language | Rust (1.15.1) |
Score | 0 |
Code Size | 1375 Byte |
Status | WA |
Exec Time | 12 ms |
Memory | 4352 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 2 ms | 4352 KB |
0_01.txt | AC | 2 ms | 4352 KB |
0_02.txt | AC | 2 ms | 4352 KB |
1_00.txt | AC | 12 ms | 4352 KB |
1_01.txt | AC | 11 ms | 4352 KB |
1_02.txt | AC | 11 ms | 4352 KB |
1_03.txt | AC | 11 ms | 4352 KB |
1_04.txt | WA | 11 ms | 4352 KB |
1_05.txt | AC | 11 ms | 4352 KB |
1_06.txt | WA | 11 ms | 4352 KB |
1_07.txt | AC | 11 ms | 4352 KB |
1_08.txt | WA | 12 ms | 4352 KB |
1_09.txt | AC | 11 ms | 4352 KB |
1_10.txt | WA | 9 ms | 4352 KB |
1_11.txt | WA | 11 ms | 4352 KB |
1_12.txt | WA | 11 ms | 4352 KB |
1_13.txt | WA | 8 ms | 4352 KB |
1_14.txt | WA | 11 ms | 4352 KB |
1_15.txt | WA | 9 ms | 4352 KB |
1_16.txt | WA | 10 ms | 4352 KB |
1_17.txt | WA | 11 ms | 4352 KB |