Submission #2237934


Source Code Expand

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using static System.Console;
using static System.Math;

//using CS_Contest.Graph;
using CS_Contest.Loop;
using CS_Contest.Utils;
using static Nakov.IO.Cin;
using static CS_Contest.IO.IO;
using static CS_Contest.Utils.MyMath;


namespace CS_Contest {
	using Li = List<int>;
	using LLi = List<List<int>>;
	using Ll = List<long>;
	using ti3 = Tuple<int, int, int>;
	using ti2 = Tuple<int, int>;
	internal class Program {
		private static void Main(string[] args) {
			var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
			SetOut(sw);
			new Calc().Solve();
			Out.Flush();
		}

		public class Calc
		{
			public void Solve() {
				//第三回 ドワンゴからの挑戦状 予選 C
				int N = NextInt();
				var A = NextIntList(N).CountUp();

				var cnt = A[4]; //4人グループは搬器1個

				//3と1を纏める。少ない方に合わせる
				var min31 = Min(A[3], A[1]);
				A[3] -= min31;
				A[1] -= min31;
				cnt += min31;

				//3組が余ってれば追加する
				cnt += A[3];

				//2人グループを2つ合わせる
				var two = A[2] / 2;
				A[2] %= 2; //残りは0か1グループ
				cnt += two;

				if (A[2] == 1) {
					//2人グループが残ってれば1人とあわせる
					A[1] = Max(A[1] - 2, 0);
					cnt++;
				}

				//1人を4人ずつまとめる
				cnt += (int) (Ceiling((double) A[1] / 4));

				cnt.WL();
			}
			
		}

	}
}
namespace Nakov.IO {
	using System;
	using System.Text;
	using System.Globalization;

	public static class Cin {
		public static string NextToken() {
			StringBuilder tokenChars = new StringBuilder();
			bool tokenFinished = false;
			bool skipWhiteSpaceMode = true;
			while (!tokenFinished) {
				int nextChar = Console.Read();
				if (nextChar == -1) {
					tokenFinished = true;
				} else {
					char ch = (char)nextChar;
					if (char.IsWhiteSpace(ch)) {
						if (!skipWhiteSpaceMode) {
							tokenFinished = true;
							if (ch == '\r' && (Environment.NewLine == "\r\n")) {
								Console.Read();
							}
						}
					} else {
						skipWhiteSpaceMode = false;
						tokenChars.Append(ch);
					}
				}
			}

			string token = tokenChars.ToString();
			return token;
		}

		public static int NextInt() {
			string token = Cin.NextToken();
			return int.Parse(token);
		}
		public static long NextLong() {
			string token = Cin.NextToken();
			return long.Parse(token);
		}
		public static double NextDouble(bool acceptAnyDecimalSeparator = true) {
			string token = Cin.NextToken();
			if (acceptAnyDecimalSeparator) {
				token = token.Replace(',', '.');
				double result = double.Parse(token, CultureInfo.InvariantCulture);
				return result;
			} else {
				double result = double.Parse(token);
				return result;
			}
		}
		public static decimal NextDecimal(bool acceptAnyDecimalSeparator = true) {
			string token = Cin.NextToken();
			if (acceptAnyDecimalSeparator) {
				token = token.Replace(',', '.');
				decimal result = decimal.Parse(token, CultureInfo.InvariantCulture);
				return result;
			} else {
				decimal result = decimal.Parse(token);
				return result;
			}
		}

	}
}

namespace CS_Contest.Loop {
	[DebuggerStepThrough]
	public static class Loop {
		public static void REP(this int n, Action<int> act) {
			for (var i = 0; i < n; i++) {
				act(i);
			}
		}

		public static void ForeachWith<T>(this IEnumerable<T> ie, Action<int, T> act) {
			var i = 0;
			foreach (var item in ie) {
				act(i, item);
				i++;
			}
		}

		public static void Foreach<T>(this IEnumerable<T> ie, Action<T> act) {
			foreach (var item in ie) {
				act(item);
			}
		}

		
	}

	public class Generate
	{
		public static IEnumerable<int> Seq(int s, int e) => Seq(s, e, 1);
		public static IEnumerable<int> Seq(int s, int e, int a) {
			while (s != e) {
				yield return s;
				s += a;
			}
		}
		public static List<T> Repeat<T>(Func<int, T> result, int range) =>
			Enumerable.Range(0, range).Select(result).ToList();
	}
}

namespace CS_Contest.IO {
	using Li = List<int>;
	using Ll = List<long>;

	public static class IO {
		public static void WL(this object obj) => WriteLine(obj);
		public static void WL(this string obj) => WriteLine(obj);
		public static void WL<T>(this IEnumerable<T> list) => list.ToList().ForEach(x => x.WL());

		public static Li NextIntList() => ReadLine().Split().Select(int.Parse).ToList();
		public static Li NextIntList(int n) => Enumerable.Repeat(0, n).Select(x => ReadLine()).Select(int.Parse).ToList();
		public static Ll NextLongList() => ReadLine().Split().Select(long.Parse).ToList();

		public static T Tee<T>(this T t, Func<T, string> formatter = null) {
			if (formatter == null) formatter = arg => arg.ToString();
			formatter(t).WL();
			return t;
		}
		public static void JoinWL<T>(this IEnumerable<T> @this, string sp = " ") => @this.StringJoin(sp).WL();
		public static void W(this object @this) => Write(@this);
	}


}

namespace CS_Contest.Utils {
	using Li = List<int>;
	using Ll = List<long>;
	[DebuggerStepThrough]
	public static class Utils {
		

		public static bool Within(int x, int y, int lx, int ly) => !(x < 0 || x >= lx || y < 0 || y >= ly);

		public static void Add<T1, T2>(this List<Tuple<T1, T2>> list, T1 t1, T2 t2) => list.Add(new Tuple<T1, T2>(t1, t2));

		public static string StringJoin<T>(this IEnumerable<T> l, string separator = "") => string.Join(separator, l);

		public static Queue<T> ToQueue<T>(this IEnumerable<T> iEnumerable) {
			var rt = new Queue<T>();
			foreach (var item in iEnumerable) {
				rt.Enqueue(item);
			}
			return rt;
		}
		public static void Swap<T>(ref T x, ref T y) {
			var tmp = x;
			x = y;
			y = tmp;
		}
		public static Map<TKey, int> CountUp<TKey>(this IEnumerable<TKey> l) {
			var dic = new Map<TKey, int>();
			foreach (var item in l) {
				if (dic.ContainsKey(item)) dic[item]++;
				else dic.Add(item, 1);
			}
			return dic;
		}
		public static int Count<T>(this IEnumerable<T> l, T target) => l.Count(x => x.Equals(target));

		public static IEnumerable<T> SkipAt<T>(this IEnumerable<T> @this, int at) {
			var enumerable = @this as T[] ?? @this.ToArray();
			for (var i = 0; i < enumerable.Count(); i++) {
				if (i == at) continue;
				yield return enumerable.ElementAt(i);
			}
		}
	}

	public class Map<TKey, TValue> : Dictionary<TKey, TValue> {
		public Map() : base() { }
		public Map(int capacity) : base(capacity) { }

		public new TValue this[TKey index] {
			get {
				TValue v;
				return this.TryGetValue(index, out v) ? v : base[index] = default(TValue);
			}
			set { base[index] = value; }
		}
	}

	public static class MyMath {
		
		public static T EMin<T>(params T[] a) where T : IComparable<T> => a.Min();
		public static T EMax<T>(params T[] a) where T : IComparable<T> => a.Max();

	}


}

Submission Info

Submission Time
Task C - スキーリフトの相乗り
User xztaityozx
Language C# (Mono 4.6.2.0)
Score 400
Code Size 7107 Byte
Status AC
Exec Time 71 ms
Memory 16480 KB

Judge Result

Set Name All
Score / Max Score 400 / 400
Status
AC × 49
Set Name Test Cases
All 00_sample00, 00_sample01, 100_corner0000, 100_corner0001, 100_corner0002, 100_corner0003, 10_small-0000, 10_small-0001, 10_small-0002, 10_small-0003, 10_small-0004, 10_small-0005, 10_small-0006, 10_small-0007, 10_small-0008, 10_small-0009, 20_special-0000, 20_special-0001, 20_special-0002, 20_special-0003, 20_special-0004, 20_special-0005, 20_special-0006, 20_special-0007, 20_special-0008, 20_special-0009, 20_special-0010, 20_special-0011, 20_special-0012, 20_special-0013, 20_special-0014, 30_large-0000, 30_large-0001, 30_large-0002, 30_large-0003, 30_large-0004, 30_large-0005, 30_large-0006, 30_large-0007, 30_large-0008, 30_large-0009, 80_combination-type00, 80_combination-type01, 80_combination-type02, 80_combination-type03, 80_combination-type04, 80_combination-type05, 80_combination-type06, 90_tayama-killer00
Case Name Status Exec Time Memory
00_sample00 AC 28 ms 11480 KB
00_sample01 AC 27 ms 11360 KB
100_corner0000 AC 28 ms 11360 KB
100_corner0001 AC 28 ms 11360 KB
100_corner0002 AC 27 ms 13408 KB
100_corner0003 AC 27 ms 9312 KB
10_small-0000 AC 27 ms 11360 KB
10_small-0001 AC 28 ms 13408 KB
10_small-0002 AC 27 ms 11360 KB
10_small-0003 AC 28 ms 13408 KB
10_small-0004 AC 27 ms 11360 KB
10_small-0005 AC 28 ms 11360 KB
10_small-0006 AC 28 ms 11360 KB
10_small-0007 AC 27 ms 11360 KB
10_small-0008 AC 27 ms 11360 KB
10_small-0009 AC 27 ms 11360 KB
20_special-0000 AC 28 ms 11360 KB
20_special-0001 AC 27 ms 9312 KB
20_special-0002 AC 28 ms 11360 KB
20_special-0003 AC 28 ms 11360 KB
20_special-0004 AC 27 ms 9312 KB
20_special-0005 AC 28 ms 11348 KB
20_special-0006 AC 27 ms 11360 KB
20_special-0007 AC 27 ms 11360 KB
20_special-0008 AC 28 ms 11360 KB
20_special-0009 AC 27 ms 11360 KB
20_special-0010 AC 27 ms 11360 KB
20_special-0011 AC 28 ms 11360 KB
20_special-0012 AC 27 ms 9312 KB
20_special-0013 AC 28 ms 11360 KB
20_special-0014 AC 28 ms 13396 KB
30_large-0000 AC 65 ms 16480 KB
30_large-0001 AC 68 ms 14432 KB
30_large-0002 AC 65 ms 14432 KB
30_large-0003 AC 71 ms 14432 KB
30_large-0004 AC 65 ms 14432 KB
30_large-0005 AC 67 ms 14432 KB
30_large-0006 AC 65 ms 14432 KB
30_large-0007 AC 67 ms 14432 KB
30_large-0008 AC 67 ms 14432 KB
30_large-0009 AC 65 ms 14432 KB
80_combination-type00 AC 28 ms 11360 KB
80_combination-type01 AC 28 ms 9312 KB
80_combination-type02 AC 28 ms 11360 KB
80_combination-type03 AC 28 ms 13408 KB
80_combination-type04 AC 28 ms 11360 KB
80_combination-type05 AC 28 ms 11360 KB
80_combination-type06 AC 27 ms 11360 KB
90_tayama-killer00 AC 28 ms 13396 KB