結果

問題 No.1096 Range Sums
ユーザー tentententen
提出日時 2022-08-04 14:39:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 1,045 bytes
コンパイル時間 3,567 ms
コンパイル使用メモリ 72,144 KB
実行使用メモリ 55,856 KB
最終ジャッジ日時 2023-10-12 12:11:58
合計ジャッジ時間 5,022 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,400 KB
testcase_01 AC 44 ms
49,252 KB
testcase_02 AC 44 ms
49,228 KB
testcase_03 AC 43 ms
49,468 KB
testcase_04 AC 43 ms
49,272 KB
testcase_05 AC 44 ms
49,356 KB
testcase_06 AC 43 ms
49,300 KB
testcase_07 AC 43 ms
49,220 KB
testcase_08 AC 43 ms
49,260 KB
testcase_09 AC 43 ms
49,340 KB
testcase_10 AC 201 ms
55,632 KB
testcase_11 AC 206 ms
55,768 KB
testcase_12 AC 202 ms
55,688 KB
testcase_13 AC 214 ms
55,608 KB
testcase_14 AC 204 ms
55,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

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

class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0