結果
問題 |
No.1096 Range Sums
|
ユーザー |
![]() |
提出日時 | 2021-04-21 09:26:01 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 574 bytes |
コンパイル時間 | 1,023 ms |
コンパイル使用メモリ | 103,936 KB |
実行使用メモリ | 39,396 KB |
最終ジャッジ日時 | 2024-07-04 05:54:25 |
合計ジャッジ時間 | 2,311 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; public class Hello { static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, long.Parse); getAns(n, a); } static void getAns(int n, long[] a) { var sum = 0L; var n2 = n / 2; for (long i = 0; i < n2; i++) { sum += (i + 1) * (n - i) * (a[i] + a[n - 1 - i]); } if (n % 2 == 1) sum += (n2 + 1) * (n - n2) * a[n2]; Console.WriteLine(sum); } }