Submission #15380

# Submission time Handle Problem Language Result Execution time Memory
15380 2015-07-12T06:56:23 Z wlgns88 달리는 게임 (kriii3_E) C++
70 / 70
155 ms 12800 KB
#include <stdio.h>
 
long long int item[1000000];
int check[1000000];
 
int main()
{
    int n, i;
    long long int result = 0;
 
    scanf("%d", &n);
    for ( i = 0; i < n; i++ )
        scanf("%lld", &item[i]);
 
    i = n-1;
    while ( i >= 0 ) {
        long long int sum = 0;
         
        while ( i >= 0 && item[i] <= 0 )
            i--;

		while ( i >= 0 && sum + item[i] > 0 ) {
			check[i] = 1;
            sum += item[i--];
		}
    }
 
    for ( i = 0; i < n; i++ ) {
        int cnt = 1;
 
        while ( i < n && check[i] == 1 )
            result += item[i++] * cnt++;
    }
 
    printf("%lld\n", result);
 
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 12800 KB Output is correct
2 Correct 1 ms 12800 KB Output is correct
3 Correct 0 ms 12800 KB Output is correct
4 Correct 0 ms 12800 KB Output is correct
5 Correct 0 ms 12800 KB Output is correct
6 Correct 0 ms 12800 KB Output is correct
7 Correct 0 ms 12800 KB Output is correct
8 Correct 0 ms 12800 KB Output is correct
9 Correct 0 ms 12800 KB Output is correct
10 Correct 0 ms 12800 KB Output is correct
11 Correct 0 ms 12800 KB Output is correct
12 Correct 0 ms 12800 KB Output is correct
13 Correct 0 ms 12800 KB Output is correct
14 Correct 0 ms 12800 KB Output is correct
15 Correct 0 ms 12800 KB Output is correct
16 Correct 0 ms 12800 KB Output is correct
17 Correct 0 ms 12800 KB Output is correct
18 Correct 0 ms 12800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 12800 KB Output is correct
2 Correct 0 ms 12800 KB Output is correct
3 Correct 0 ms 12800 KB Output is correct
4 Correct 0 ms 12800 KB Output is correct
5 Correct 0 ms 12800 KB Output is correct
6 Correct 0 ms 12800 KB Output is correct
7 Correct 66 ms 12800 KB Output is correct
8 Correct 155 ms 12800 KB Output is correct
9 Correct 143 ms 12800 KB Output is correct