Submission #8583386
Source Code Expand
Copy
use std::io::*; use std::str::FromStr; fn main() { let m: usize = read(); let mut d: Vec<usize> = vec![0; m]; let mut c: Vec<usize> = vec![0; m]; for i in 0..m { d[i] = read(); c[i] = read(); } let mut sum = 0; let po = [(10, 10), (10, 11), (4, 4), (10, 13), (10, 14), (4, 5), (28, 48), (64, 119), (2, 2)]; for i in 0..m { if d[i] == 0 { sum += c[i]; c[i] = 0; continue; } let (p, o) = po[d[i]-1]; sum += (c[i] / p) * o; c[i] = c[i] / p + c[i] % p; }/* for i in 0..m { println!("{}:{}", d[i], c[i]); }*/ let mut now = 0; for i in 0..m { while c[i] > 0 { now += d[i]; c[i] -= 1; sum += 1; while now > 9 { now = now % 10 + now / 10; sum += 1; } } } //println!("{}", now); println!("{}", sum-1); } fn read<T: FromStr>() -> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.unwrap() as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().unwrap() }
Submission Info
Submission Time | |
---|---|
Task | D - Digit Sum Replace |
User | mds_boy |
Language | Rust (1.15.1) |
Score | 0 |
Code Size | 1339 Byte |
Status | TLE |
Exec Time | 2103 ms |
Memory | 8444 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 500 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00-sample-01.txt, 00-sample-02.txt |
All | 00-sample-01.txt, 00-sample-02.txt, 01-corner-01.txt, 01-corner-02.txt, 01-corner-03.txt, 02-random-01.txt, 02-random-02.txt, 02-random-03.txt, 02-random-04.txt, 02-random-05.txt, 02-random-06.txt, 02-random-07.txt, 02-random-08.txt, 02-random-09.txt, 02-random-10.txt, 02-random-11.txt, 03-max-01.txt, 03-max-02.txt, 04-min-01.txt, 04-min-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00-sample-01.txt | AC | 2 ms | 4352 KB |
00-sample-02.txt | AC | 2 ms | 4352 KB |
01-corner-01.txt | AC | 2 ms | 4352 KB |
01-corner-02.txt | AC | 2 ms | 4352 KB |
01-corner-03.txt | AC | 2 ms | 4352 KB |
02-random-01.txt | AC | 2 ms | 4352 KB |
02-random-02.txt | AC | 2 ms | 4352 KB |
02-random-03.txt | AC | 2 ms | 4352 KB |
02-random-04.txt | AC | 2 ms | 4352 KB |
02-random-05.txt | AC | 2 ms | 4352 KB |
02-random-06.txt | TLE | 2103 ms | 8444 KB |
02-random-07.txt | TLE | 2103 ms | 8444 KB |
02-random-08.txt | TLE | 2103 ms | 8444 KB |
02-random-09.txt | TLE | 2103 ms | 6396 KB |
02-random-10.txt | TLE | 2103 ms | 8444 KB |
02-random-11.txt | TLE | 2103 ms | 8444 KB |
03-max-01.txt | TLE | 2103 ms | 6396 KB |
03-max-02.txt | TLE | 2103 ms | 4352 KB |
04-min-01.txt | TLE | 2103 ms | 6396 KB |
04-min-02.txt | TLE | 2103 ms | 4352 KB |