Submission #15420

#TimeUsernameProblemLanguageResultExecution timeMemory
15420xhae달리는 게임 (kriii3_E)C++14
26 / 70
1000 ms5628 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]); long long res = 0; long long mult = 0; for (int i=0; i<n; i++) { long long sum = 0; for (int j=i; j<n; j++) { sum += val[j]; if (sum >= 0) break; } if (sum >= 0) { mult ++; res += mult * val[i]; } else mult = 0; } printf("%lld\n", res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...