[Init] Solved solutions

This commit is contained in:
tiennm99 committed 2023-03-02 20:58:03 +07:00
1 parent 51f667ac81
commit 20542601dd
131 files changed
+4148

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
using System;
namespace problem_381A
{
class problem_381A
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] b = new int[n];
int l = 0, r = n - 1, s1 = 0, s2 = 0;
for (int i = 0; i < n; i++)
{
if (a[l] >= a[r])
{
b[i] = a[l++];
}
else
{
b[i] = a[r--];
}
}
for (int i = 0; i < n; i++)
{
if (i % 2 == 0)
{
s1 += b[i];
}
else
{
s2 += b[i];
}
}
Console.Write("{0} {1}", s1, s2);
}
}
}