結果
問題 | No.1219 Mancala Combo |
ユーザー | terry_u16 |
提出日時 | 2020-09-04 21:57:20 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 110 ms / 2,000 ms |
コード長 | 8,379 bytes |
コンパイル時間 | 1,237 ms |
コンパイル使用メモリ | 114,228 KB |
実行使用メモリ | 40,632 KB |
最終ジャッジ日時 | 2024-11-26 12:44:16 |
合計ジャッジ時間 | 3,755 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 31 ms
21,180 KB |
testcase_01 | AC | 31 ms
20,784 KB |
testcase_02 | AC | 31 ms
21,168 KB |
testcase_03 | AC | 31 ms
21,048 KB |
testcase_04 | AC | 35 ms
21,680 KB |
testcase_05 | AC | 35 ms
21,820 KB |
testcase_06 | AC | 31 ms
21,048 KB |
testcase_07 | AC | 36 ms
21,688 KB |
testcase_08 | AC | 36 ms
21,676 KB |
testcase_09 | AC | 32 ms
20,916 KB |
testcase_10 | AC | 32 ms
21,048 KB |
testcase_11 | AC | 35 ms
21,556 KB |
testcase_12 | AC | 31 ms
20,792 KB |
testcase_13 | AC | 34 ms
21,556 KB |
testcase_14 | AC | 31 ms
21,040 KB |
testcase_15 | AC | 31 ms
21,052 KB |
testcase_16 | AC | 32 ms
21,180 KB |
testcase_17 | AC | 89 ms
36,912 KB |
testcase_18 | AC | 90 ms
37,424 KB |
testcase_19 | AC | 74 ms
31,288 KB |
testcase_20 | AC | 93 ms
37,684 KB |
testcase_21 | AC | 68 ms
29,872 KB |
testcase_22 | AC | 85 ms
36,028 KB |
testcase_23 | AC | 100 ms
38,712 KB |
testcase_24 | AC | 70 ms
29,864 KB |
testcase_25 | AC | 74 ms
30,776 KB |
testcase_26 | AC | 90 ms
37,304 KB |
testcase_27 | AC | 107 ms
39,856 KB |
testcase_28 | AC | 110 ms
40,632 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using YukicoderContest264.Extensions; using YukicoderContest264.Questions; namespace YukicoderContest264.Questions { /// <summary> /// https://yukicoder.me/problems/no/1219 /// </summary> public class QuestionC : AtCoderQuestionBase { public override IEnumerable<object> Solve(TextReader inputStream) { _ = inputStream.ReadIntArray(); var stones = inputStream.ReadLongArray(); var removed = new long[stones.Length]; for (int i = 0; i < stones.Length; i++) { var needed = i + 1; if (stones[i] > needed) { yield return "No"; yield break; } else if (stones[i] == needed) { removed[i]++; stones[i] = 0; } } long prefix = 0; for (int i = stones.Length - 1; i >= 0; i--) { var needed = i + 1; stones[i] += prefix; removed[i] += stones[i] / needed; stones[i] %= needed; prefix += removed[i]; } yield return stones.All(si => si == 0) ? "Yes" : "No"; } } } namespace YukicoderContest264 { class Program { static void Main(string[] args) { IAtCoderQuestion question = new QuestionC(); var answers = question.Solve(Console.In); var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(writer); foreach (var answer in answers) { Console.WriteLine(answer); } Console.Out.Flush(); } } } #region Base Class namespace YukicoderContest264.Questions { public interface IAtCoderQuestion { IEnumerable<object> Solve(string input); IEnumerable<object> Solve(TextReader inputStream); } public abstract class AtCoderQuestionBase : IAtCoderQuestion { public IEnumerable<object> Solve(string input) { var stream = new MemoryStream(Encoding.Unicode.GetBytes(input)); var reader = new StreamReader(stream, Encoding.Unicode); return Solve(reader); } public abstract IEnumerable<object> Solve(TextReader inputStream); } } #endregion #region Extensions namespace YukicoderContest264.Extensions { public static class StringExtensions { public static string Join<T>(this IEnumerable<T> source) => string.Concat(source); public static string Join<T>(this IEnumerable<T> source, char separator) => string.Join(separator, source); public static string Join<T>(this IEnumerable<T> source, string separator) => string.Join(separator, source); } public static class TextReaderExtensions { public static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader)); public static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader)); public static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader)); public static string ReadString(this TextReader reader) => reader.ReadLine(); public static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray(); public static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray(); public static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray(); public static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator); // Supports primitive type only. public static T1 ReadValue<T1>(this TextReader reader) => (T1)Convert.ChangeType(reader.ReadLine(), typeof(T1)); public static (T1, T2) ReadValue<T1, T2>(this TextReader reader, char separator = ' ') { var inputs = ReadStringArray(reader, separator); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); return (v1, v2); } public static (T1, T2, T3) ReadValue<T1, T2, T3>(this TextReader reader, char separator = ' ') { var inputs = ReadStringArray(reader, separator); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); return (v1, v2, v3); } public static (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>(this TextReader reader, char separator = ' ') { var inputs = ReadStringArray(reader, separator); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); return (v1, v2, v3, v4); } public static (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>(this TextReader reader, char separator = ' ') { var inputs = ReadStringArray(reader, separator); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); return (v1, v2, v3, v4, v5); } public static (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>(this TextReader reader, char separator = ' ') { var inputs = ReadStringArray(reader, separator); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); return (v1, v2, v3, v4, v5, v6); } public static (T1, T2, T3, T4, T5, T6, T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>(this TextReader reader, char separator = ' ') { var inputs = ReadStringArray(reader, separator); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7)); return (v1, v2, v3, v4, v5, v6, v7); } public static (T1, T2, T3, T4, T5, T6, T7, T8) ReadValue<T1, T2, T3, T4, T5, T6, T7, T8>(this TextReader reader, char separator = ' ') { var inputs = ReadStringArray(reader, separator); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7)); var v8 = (T8)Convert.ChangeType(inputs[7], typeof(T8)); return (v1, v2, v3, v4, v5, v6, v7, v8); } } } #endregion