結果
問題 | No.1618 Convolution? |
ユーザー | さかぽん |
提出日時 | 2021-07-22 22:53:31 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 398 ms / 2,000 ms |
コード長 | 1,201 bytes |
コンパイル時間 | 5,209 ms |
コンパイル使用メモリ | 108,000 KB |
実行使用メモリ | 64,988 KB |
最終ジャッジ日時 | 2023-09-24 18:34:12 |
合計ジャッジ時間 | 14,262 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 66 ms
23,772 KB |
testcase_01 | AC | 65 ms
21,800 KB |
testcase_02 | AC | 259 ms
48,440 KB |
testcase_03 | AC | 294 ms
55,120 KB |
testcase_04 | AC | 269 ms
58,432 KB |
testcase_05 | AC | 88 ms
23,928 KB |
testcase_06 | AC | 329 ms
56,632 KB |
testcase_07 | AC | 333 ms
56,704 KB |
testcase_08 | AC | 274 ms
55,988 KB |
testcase_09 | AC | 381 ms
64,988 KB |
testcase_10 | AC | 288 ms
44,056 KB |
testcase_11 | AC | 365 ms
58,800 KB |
testcase_12 | AC | 388 ms
62,016 KB |
testcase_13 | AC | 384 ms
55,832 KB |
testcase_14 | AC | 393 ms
61,848 KB |
testcase_15 | AC | 398 ms
55,824 KB |
testcase_16 | AC | 394 ms
59,976 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.Linq; class C { static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse); static (int, int) Read2() { var a = Read(); return (a[0], a[1]); } static long[] ReadL() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse); static void Main() => Console.WriteLine(Solve()); static object Solve() { var n = int.Parse(Console.ReadLine()); var a = ReadL(); var b = ReadL(); var ab = a.Zip(b, (x, y) => x + y).ToArray(); var rsq = new StaticRSQ1(ab); var c = new long[2 * n]; var t = 0L; for (int i = 1; i <= n; i++) { t += rsq.GetSum(0, i); c[i] = t; } for (int i = 1; i < n; i++) { t -= n * ab[i - 1]; t += rsq.GetSum(i, n); c[n + i] = t; } return string.Join(" ", c); } } public class StaticRSQ1 { int n; long[] s; public long[] Raw => s; public StaticRSQ1(long[] a) { n = a.Length; s = new long[n + 1]; for (int i = 0; i < n; ++i) s[i + 1] = s[i] + a[i]; } // [l, r) // 範囲外のインデックスも可。 public long GetSum(int l, int r) { if (r < 0 || n < l) return 0; if (l < 0) l = 0; if (n < r) r = n; return s[r] - s[l]; } }