Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use proconio::{input, marker::Usize1}; | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
q: usize, | ||
a: [i64; n], | ||
lrv: [(Usize1, Usize1, i64); q], | ||
}; | ||
let mut x = 0; | ||
// a[0] a[1] | ||
// b[0] | ||
let mut b = vec![0; n]; | ||
let mut p = a[0]; | ||
for (i, &a_i) in a.iter().enumerate().skip(1) { | ||
b[i] = a_i - p; | ||
x += b[i].abs(); | ||
p = a_i; | ||
} | ||
for (l_i, r_i, v_i) in lrv { | ||
if l_i > 0 { | ||
x -= b[l_i].abs(); | ||
b[l_i] += v_i; | ||
x += b[l_i].abs(); | ||
} | ||
if r_i < n - 1 { | ||
x -= b[r_i + 1].abs(); | ||
b[r_i + 1] -= v_i; | ||
x += b[r_i + 1].abs(); | ||
} | ||
let ans = x; | ||
println!("{}", ans); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use proconio::input; | ||
use proconio::marker::Usize1; | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
a: [Usize1; n], | ||
}; | ||
let ans = n - a.len(); | ||
println!("{}", ans); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use proconio::input; | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
lr: [(i64, i64); n], | ||
}; | ||
let mut ans = 0_f64; | ||
for i in 0..n { | ||
for j in i + 1..n { | ||
let (l_i, r_i) = lr[i]; | ||
let (l_j, r_j) = lr[j]; | ||
let all = (r_i - l_i + 1) * (r_j - l_j + 1); | ||
let mut count = 0_i64; | ||
for v_i in l_i..=r_i { | ||
for v_j in l_j..=r_j { | ||
if v_i > v_j { | ||
count += 1; | ||
} | ||
} | ||
} | ||
ans += count as f64 / all as f64; | ||
} | ||
} | ||
println!("{}", ans); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use proconio::{input, marker::Chars}; | ||
|
||
fn main() { | ||
input! { | ||
mut n: Chars, | ||
k: usize, | ||
}; | ||
for _ in 0..k { | ||
let mut d = u64::from_str_radix(n.iter().collect::<String>().as_str(), 8).unwrap(); | ||
if d == 0 { | ||
println!("0"); | ||
return; | ||
} | ||
let mut s = vec![]; | ||
while d > 0 { | ||
let d_i = (d % 9) as u8; | ||
let d_i = if d_i == 8 { 5 } else { d_i }; | ||
s.push((d_i + b'0') as char); | ||
d /= 9; | ||
} | ||
s.reverse(); | ||
n = s; | ||
} | ||
let ans = n.iter().collect::<String>(); | ||
println!("{}", ans); | ||
} |