Submission #15353

#TimeUsernameProblemLanguageResultExecution timeMemory
15353wlgns88달리는 게임 (kriii3_E)C++98
0 / 70
0 ms12800 KiB
#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 && item[i] >= 0 ) { check[i] = 1; sum += item[i--]; } while ( i >= 0 && item[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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...