Task: | Equilateral numbers |
Sender: | Viestipojat |
Submission time: | 2024-11-16 12:25:35 +0200 |
Language: | Rust (2021) |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | TIME LIMIT EXCEEDED | -- | details |
#2 | TIME LIMIT EXCEEDED | -- | details |
#3 | TIME LIMIT EXCEEDED | -- | details |
#4 | TIME LIMIT EXCEEDED | -- | details |
#5 | TIME LIMIT EXCEEDED | -- | details |
#6 | TIME LIMIT EXCEEDED | -- | details |
#7 | TIME LIMIT EXCEEDED | -- | details |
#8 | TIME LIMIT EXCEEDED | -- | details |
#9 | TIME LIMIT EXCEEDED | -- | details |
#10 | TIME LIMIT EXCEEDED | -- | details |
#11 | TIME LIMIT EXCEEDED | -- | details |
#12 | TIME LIMIT EXCEEDED | -- | details |
Code
use std::str::FromStr; use std::fmt::Debug; fn read<T: FromStr>() -> Vec<T>where <T as FromStr>::Err: Debug { let stdin = std::io::stdin(); let line = stdin.lines().next().unwrap().unwrap(); line.split_whitespace().map(T::from_str).map(|x| x.unwrap()).collect() } fn main() { let n = read::<usize>()[0]; let nums = (1..=1_501_000).map(|n| n * (n + 1) / 2).collect::<Vec<_>>(); let mut r = vec![0; 1_501_000]; r[1] = 1; for i in 2..1_501_000 { r[i] = 1 + nums.iter().take_while(|s| i >= **s).map(|s| r[i - s]).min().unwrap(); } println!("{}", 1 + nums.iter().filter_map(|s| r.get(n.wrapping_sub(*s))).min().unwrap() ) }
Test details
Test 1
Verdict: TIME LIMIT EXCEEDED
input |
---|
1 |
correct output |
---|
1 |
user output |
---|
(empty) |
Test 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
2 |
correct output |
---|
2 |
user output |
---|
(empty) |
Test 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
3 |
correct output |
---|
1 |
user output |
---|
(empty) |
Test 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
5 |
correct output |
---|
3 |
user output |
---|
(empty) |
Test 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
33 |
correct output |
---|
3 |
user output |
---|
(empty) |
Test 6
Verdict: TIME LIMIT EXCEEDED
input |
---|
12385719843 |
correct output |
---|
3 |
user output |
---|
(empty) |
Test 7
Verdict: TIME LIMIT EXCEEDED
input |
---|
10935032 |
correct output |
---|
3 |
user output |
---|
(empty) |
Test 8
Verdict: TIME LIMIT EXCEEDED
input |
---|
659023495928 |
correct output |
---|
3 |
user output |
---|
(empty) |
Test 9
Verdict: TIME LIMIT EXCEEDED
input |
---|
913591235689 |
correct output |
---|
2 |
user output |
---|
(empty) |
Test 10
Verdict: TIME LIMIT EXCEEDED
input |
---|
999999911791 |
correct output |
---|
1 |
user output |
---|
(empty) |
Test 11
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000000000000 |
correct output |
---|
2 |
user output |
---|
(empty) |
Test 12
Verdict: TIME LIMIT EXCEEDED
input |
---|
999999999998 |
correct output |
---|
3 |
user output |
---|
(empty) |