Submission #16786415


Source Code Expand

Copy
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    };
    let mut l = 0;
    let mut r = n - 1;
    let mut sum_l = a[l];
    let mut sum_r = a[r];
    while r - l > 1 {
        if sum_l < sum_r {
            l += 1;
            sum_l += a[l];
        } else {
            r -= 1;
            sum_r += a[r];
        }
    }
    let ans = (sum_r - sum_l).abs();
    println!("{}", ans);
}

Submission Info

Submission Time
Task B - Iron Bar Cutting
User bouzuya
Language Rust (1.42.0)
Score 200
Code Size 427 Byte
Status AC
Exec Time 32 ms
Memory 5528 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 20
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
in01.txt AC 9 ms 1940 KB
in02.txt AC 3 ms 1984 KB
in03.txt AC 2 ms 1916 KB
in04.txt AC 2 ms 1864 KB
in05.txt AC 1 ms 1920 KB
in06.txt AC 1 ms 1996 KB
in07.txt AC 32 ms 5360 KB
in08.txt AC 24 ms 5468 KB
in09.txt AC 24 ms 5440 KB
in10.txt AC 26 ms 5424 KB
in11.txt AC 24 ms 5400 KB
in12.txt AC 23 ms 5432 KB
in13.txt AC 24 ms 5356 KB
in14.txt AC 28 ms 5424 KB
in15.txt AC 19 ms 5468 KB
in16.txt AC 25 ms 5436 KB
in17.txt AC 27 ms 5528 KB
in18.txt AC 1 ms 2040 KB
sample_01.txt AC 1 ms 2072 KB
sample_02.txt AC 3 ms 2084 KB