結果

問題 No.1096 Range Sums
ユーザー TententenTententen
提出日時 2020-12-14 12:27:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 675 ms / 2,000 ms
コード長 409 bytes
コンパイル時間 2,161 ms
コンパイル使用メモリ 74,220 KB
実行使用メモリ 67,220 KB
最終ジャッジ日時 2023-10-20 04:57:27
合計ジャッジ時間 8,170 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
57,208 KB
testcase_01 AC 133 ms
57,372 KB
testcase_02 AC 131 ms
57,372 KB
testcase_03 AC 133 ms
57,448 KB
testcase_04 AC 132 ms
57,184 KB
testcase_05 AC 133 ms
57,672 KB
testcase_06 AC 135 ms
57,464 KB
testcase_07 AC 135 ms
57,440 KB
testcase_08 AC 136 ms
57,468 KB
testcase_09 AC 138 ms
57,528 KB
testcase_10 AC 675 ms
67,220 KB
testcase_11 AC 630 ms
66,604 KB
testcase_12 AC 630 ms
66,688 KB
testcase_13 AC 656 ms
66,684 KB
testcase_14 AC 626 ms
64,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		long ans = 0;
		for (int i = 0; i < n; i++) {
		    long left = i + 1;
		    long right = n - i;
		    ans += arr[i] * left * right;
		}
		System.out.println(ans);
	}
}
0