use std::io::{self, Stdin}; use std::str::{self, FromStr}; use std::error::Error; use std::collections::BTreeSet; fn exec() { let mut sc = Scanner::new(); let n: usize = sc.ne(); let d: usize = sc.ne(); let k: i64 = sc.ne(); let a: Vec = (0..n).map(|_| sc.ne()).collect(); let mut s = BTreeSet::new(); for i in 0..d { s.insert((a[i], i as i32 * -1)); } let mut ma = 0; let mut id = (0, 0); for i in 0..n { let nxt = i + d; if nxt < n { s.insert((a[nxt], nxt as i32 * -1)); } s.remove(&(a[i], i as i32 * -1)); if let Some(x) = s.iter().rev().next() { let tmp = x.0 - a[i]; if ma < tmp { ma = tmp; id = (i, (x.1 * -1) as usize); } } } println!("{}", ma * k); if ma != 0 { println!("{} {}", id.0, id.1); } } fn main() { const STACK: usize = 16 * 1024 * 1024; let _ = std::thread::Builder::new() .stack_size(STACK) .spawn(|| { exec(); }) .unwrap() .join() .unwrap(); } #[allow(dead_code)] struct Scanner { stdin: Stdin, id: usize, buf: Vec, } #[allow(dead_code)] impl Scanner { fn new() -> Scanner { Scanner { stdin: io::stdin(), id: 0, buf: Vec::new(), } } fn next_line(&mut self) -> Option { let mut res = String::new(); match self.stdin.read_line(&mut res) { Ok(0) => None, Ok(_) => Some(res), Err(why) => panic!("error in read_line: {}", why.description()), } } fn next(&mut self) -> Option { while self.buf.len() == 0 { self.buf = match self.next_line() { Some(r) => { self.id = 0; r.trim().as_bytes().to_owned() } None => return None, }; } let l = self.id; assert!(self.buf[l] != b' '); let n = self.buf.len(); let mut r = l; while r < n && self.buf[r] != b' ' { r += 1; } let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::() { Ok(s) => Some(s), Err(_) => { panic!("parse error, {:?}", String::from_utf8(self.buf[l..r].to_owned())) } }; while r < n && self.buf[r] == b' ' { r += 1; } if r == n { self.buf.clear(); } else { self.id = r; } res } fn ne(&mut self) -> T { self.next::().unwrap() } }