結果
問題 | No.1096 Range Sums |
ユーザー |
![]() |
提出日時 | 2021-04-21 09:20:40 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 561 bytes |
コンパイル時間 | 848 ms |
コンパイル使用メモリ | 107,876 KB |
実行使用メモリ | 33,536 KB |
最終ジャッジ日時 | 2024-07-04 05:54:05 |
合計ジャッジ時間 | 2,112 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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;for (long i = 0; i < n / 2; i++){sum += (i + 1) * (n - i) * (a[i] + a[n - 1 - i]);}if (n % 2 == 1) sum += (n / 2 + 1) * (n - n / 2) * a[n / 2];Console.WriteLine(sum);}}