제출 #15427

#제출 시각아이디문제언어결과실행 시간메모리
15427yukariko달리는 게임 (kriii3_E)C++98
0 / 70
0 ms2376 KiB
#include <iostream> using namespace std; int abs(int n) { if (n < 0) return n*-1; return n; } int main() { int n, factor=0; int sum[100000] = {}; int num[100000] = {}; int result=0; cin >> n; for (int i = 0; i < n; i++) { cin >> num[i]; sum[0] += num[i]; } for (int i = 1; i < n; i++) sum[i] = sum[i - 1] - num[i - 1]; for (int i = 0; i < n; i++) { factor++; if (num[i] >= 0) { result += num[i] * factor; } else { if (abs(num[i] * factor) < sum[i] * factor) result += num[i] * factor; else factor = 0; } } cout << result << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...