Happy Subarrays
시간 제한25초메모리 제한1024 MB
모든 접두사 합이 음수가 아닌 부분 배열들의 합을 모두 더한 값을 구한다.
문제
Let us define as the sum of a subarray of an array bounded by indices and (both inclusive). Formally, .
An array of length is called a happy array if all the prefix sums of are non-negative. Formally, the terms are all non-negative.
Given an array of integers, find the result of adding the sums of all the happy subarrays in the array .
입력
The first line of the input gives the number of test cases, . test cases follow.
Each test case begins with one line consisting an integer denoting the number of integers in the input array . Then the next line contains integers representing the integers in given input array .
출력
For each test case, output one line containing Case #x: y, where is the test case number (starting from 1) and is the result of adding the sums of all happy subarrays in the given input array .
제한
- .
- , for all .