結果

問題 No.1096 Range Sums
ユーザー ks2mks2m
提出日時 2020-06-26 21:52:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 255 ms / 2,000 ms
コード長 543 bytes
コンパイル時間 2,062 ms
コンパイル使用メモリ 71,684 KB
実行使用メモリ 67,220 KB
最終ジャッジ日時 2023-09-18 05:11:49
合計ジャッジ時間 4,376 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,296 KB
testcase_01 AC 43 ms
49,256 KB
testcase_02 AC 43 ms
49,408 KB
testcase_03 AC 43 ms
49,132 KB
testcase_04 AC 43 ms
49,192 KB
testcase_05 AC 43 ms
49,228 KB
testcase_06 AC 44 ms
49,256 KB
testcase_07 AC 43 ms
49,312 KB
testcase_08 AC 43 ms
49,300 KB
testcase_09 AC 43 ms
49,464 KB
testcase_10 AC 255 ms
67,220 KB
testcase_11 AC 235 ms
66,596 KB
testcase_12 AC 237 ms
66,884 KB
testcase_13 AC 235 ms
66,528 KB
testcase_14 AC 224 ms
66,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		long ans = 0;
		for (int i = 0; i < n; i++) {
			ans += (long) (i + 1) * (n - i) * a[i];
		}
		System.out.println(ans);
	}
}
0