Submission #15457

#TimeUsernameProblemLanguageResultExecution timeMemory
15457skeksk91달리는 게임 (kriii3_E)C++98
70 / 70
224 ms16708 KiB
#include<stdio.h> double arr[1000001]; double sum[1000001]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%lf", &arr[i]); sum[i] = sum[i - 1] + arr[i]; } int tail = n; double ans = 0; for (int i = n; i >= 1; i--) { if (sum[tail] - sum[i - 1] > 0) { ans += sum[tail] - sum[i - 1]; } else { tail = i - 1; } } printf("%.0lf", ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...