Submission #4103709


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CompetitiveProgCsLib
{
	class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static int[] RIs => R.Split(' ').Select(int.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void OutLine<T>(IEnumerable<T> obj, string separateChar) => Out(String.Join(separateChar, obj));
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES" : "NO");
		static bool IsIn(int y, int x, int h, int w) => 0 <= x && x < w && 0 <= y && y < h;
		static T MIN<T>(params T[] args) => args.Min();
		static T MAX<T>(params T[] args) => args.Max();

		static void Main(string[] args)
		{
			var n = RI;
			var list = new List<long>();
			var lia = new List<int>();
			var lib = new List<int>();
			var dic = new Dictionary<long, List<int>>();
			var aa = new List<ob>();
			for (int i = 0; i < n; i++)
			{
				var ab = RIs;
				var a = ab[0];
				var b = ab[1];
				var o = new ob();
				o.obj1 = a;
				o.obj2 = b;
				o.param = a + b;
				aa.Add(o);
			}
			aa.Sort();
			aa.Reverse();
			long ans = 0;
			for(int i = 0;i < n;i++)
			{
				if(i % 2 == 0)
				{
					ans += aa[i].obj1;
				}
				else
				{
					ans -= aa[i].obj2;
				}
			}
			Out(ans);
		}
		
		class ob : IComparable
		{
			public int obj1;
			public int obj2;
			public long param;

			public int CompareTo(object obj)
			{
				return param.CompareTo(((ob)obj).param);
			}
		}
	}
}

Submission Info

Submission Time
Task C - Different Strokes
User haru_44
Language C# (Mono 4.6.2.0)
Score 400
Code Size 1750 Byte
Status AC
Exec Time 232 ms
Memory 22328 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 13
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13
Case Name Status Exec Time Memory
a01 AC 25 ms 13280 KiB
a02 AC 24 ms 9308 KiB
a03 AC 24 ms 9312 KiB
b04 AC 24 ms 11232 KiB
b05 AC 204 ms 20404 KiB
b06 AC 200 ms 22328 KiB
b07 AC 226 ms 20144 KiB
b08 AC 219 ms 20144 KiB
b09 AC 220 ms 22192 KiB
b10 AC 231 ms 20144 KiB
b11 AC 220 ms 20144 KiB
b12 AC 224 ms 20144 KiB
b13 AC 232 ms 20144 KiB