Submission #847564
Source Code Expand
Copy
using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Threading; // (づ°ω°)づミe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜ public class Solver { public void Solve() { int n = ReadInt(); int m = ReadInt(); if (m == 0) { WriteLines(Enumerable.Repeat(1, n)); return; } var a = new long[m]; for (int i = 0; i < m; i++) a[i] = ReadLong(); for (int i = m - 2; i >= 0; i--) a[i] = Math.Min(a[i], a[i + 1]); var dp = new long[m]; var pref = new long[n + 1]; dp[m - 1] = 1; for (int i = m - 1; i >= 0; i--) { int p = i - 1; long q = a[i]; while (q > 0 && p >= 0) { int l = -1, r = p; while (l < r) { int mid = (l + r + 1) / 2; if (a[mid] > q) r = mid - 1; else l = mid; } if (l == -1) break; dp[l] += q / a[l] * dp[i]; q = q % a[l]; p = l - 1; } pref[n] += q / n * dp[i]; pref[q % n] += dp[i]; } for (int i = n - 1; i > 0; i--) pref[i] += pref[i + 1]; WriteLines(pref.Skip(1)); } #region Main protected static TextReader reader; protected static TextWriter writer; static void Main() { #if DEBUG reader = new StreamReader("..\\..\\input.txt"); //reader = new StreamReader(Console.OpenStandardInput()); writer = Console.Out; //writer = new StreamWriter("..\\..\\output.txt"); #else reader = new StreamReader(Console.OpenStandardInput()); writer = new StreamWriter(Console.OpenStandardOutput()); //reader = new StreamReader("input.txt"); //writer = new StreamWriter("output.txt"); #endif try { new Solver().Solve(); //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128); //thread.Start(); //thread.Join(); } catch (Exception ex) { #if DEBUG Console.WriteLine(ex); #else throw; #endif } reader.Close(); writer.Close(); } #endregion #region Read / Write private static Queue<string> currentLineTokens = new Queue<string>(); private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); } public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); } public static int ReadInt() { return int.Parse(ReadToken()); } public static long ReadLong() { return long.Parse(ReadToken()); } public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); } public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); } public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); } public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); } public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; } public static int[][] ReadAndTransposeIntMatrix(int numberOfRows) { int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][]; for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret; } public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; } public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); } public static void Write(params object[] array) { WriteArray(array); } public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); } private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue> { public new TValue this[TKey key] { get { return ContainsKey(key) ? base[key] : default(TValue); } set { base[key] = value; } } } private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; } #endregion }
Submission Info
Submission Time | |
---|---|
Task | E - Sequential operations on Sequence |
User | azukun |
Language | C# (Mono 4.6.2.0) |
Score | 1400 |
Code Size | 5084 Byte |
Status | AC |
Exec Time | 393 ms |
Memory | 10872 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1400 / 1400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, s1.txt, s2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 304 ms | 10624 KB |
02.txt | AC | 303 ms | 10752 KB |
03.txt | AC | 304 ms | 10752 KB |
04.txt | AC | 337 ms | 10752 KB |
05.txt | AC | 393 ms | 10752 KB |
06.txt | AC | 320 ms | 10752 KB |
07.txt | AC | 329 ms | 10872 KB |
08.txt | AC | 326 ms | 10872 KB |
09.txt | AC | 329 ms | 10752 KB |
10.txt | AC | 312 ms | 10752 KB |
11.txt | AC | 311 ms | 10872 KB |
12.txt | AC | 323 ms | 10752 KB |
13.txt | AC | 330 ms | 10752 KB |
14.txt | AC | 322 ms | 10752 KB |
15.txt | AC | 319 ms | 10752 KB |
16.txt | AC | 334 ms | 10752 KB |
17.txt | AC | 326 ms | 10872 KB |
18.txt | AC | 332 ms | 10752 KB |
19.txt | AC | 320 ms | 10752 KB |
20.txt | AC | 315 ms | 10872 KB |
21.txt | AC | 315 ms | 9496 KB |
22.txt | AC | 298 ms | 10496 KB |
23.txt | AC | 329 ms | 10752 KB |
24.txt | AC | 271 ms | 10632 KB |
25.txt | AC | 272 ms | 10504 KB |
26.txt | AC | 226 ms | 9620 KB |
27.txt | AC | 195 ms | 9504 KB |
28.txt | AC | 209 ms | 9504 KB |
29.txt | AC | 216 ms | 9504 KB |
30.txt | AC | 224 ms | 9500 KB |
31.txt | AC | 38 ms | 2904 KB |
32.txt | AC | 92 ms | 7128 KB |
33.txt | AC | 38 ms | 2904 KB |
34.txt | AC | 140 ms | 9284 KB |
35.txt | AC | 38 ms | 2904 KB |
36.txt | AC | 38 ms | 2904 KB |
s1.txt | AC | 40 ms | 2904 KB |
s2.txt | AC | 40 ms | 2904 KB |