Submission #15444

# Submission time Handle Problem Language Result Execution time Memory
15444 2015-07-12T07:44:43 Z yukariko 달리는 게임 (kriii3_E) C++
0 / 70
1 ms 3156 KB
#include <iostream>

using namespace std;

int abs(int n)
{
	if (n < 0)
		return n*-1;
	return n;
}

int main()
{
	int n, factor=0;
	long long int sum[100000] = {};
	long long int num[100000] = {};
	long long 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 (i == n - 1)
				break;
			if (abs(num[i] * factor) <= sum[i+1] * factor)
				result += num[i] * factor;
			else
				factor = 0;
		}
	}

	cout << result << endl;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3152 KB Output is correct
2 Incorrect 1 ms 3156 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -