# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
15434 |
2015-07-12T07:38:49 Z |
yukariko |
달리는 게임 (kriii3_E) |
C++ |
|
0 ms |
2372 KB |
#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 (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 |
0 ms |
2372 KB |
Output is correct |
2 |
Incorrect |
0 ms |
2372 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |