Submission #15424

#TimeUsernameProblemLanguageResultExecution timeMemory
15424xhae달리는 게임 (kriii3_E)C++14
70 / 70
157 ms9536 KiB
#include <math.h> #include <stdio.h> #include <string.h> #include <vector> #include <string> #include <queue> #include <map> #include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <sstream> #include <set> using namespace std; int main() { int n; scanf("%d", &n); vector<int> val(n); for (int i=0; i<n; i++) scanf("%d", &val[i]); vector<int> mark(n); long long sum = 0; for (int i=n-1; i>=0; i--) { sum = max(sum + val[i], 0LL + val[i]); if (sum >= 0) mark[i] = 1; } long long res = 0; long long mult = 0; for (int i=0; i<n; i++) { if (mark[i]) { mult ++; res += mult * val[i]; } else mult = 0; } printf("%lld\n", res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...