結果

問題 No.2938 Sigma Sigma Distance Distance Problem
ユーザー じきお。
提出日時 2024-11-26 12:16:34
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 493 bytes
コンパイル時間 2,593 ms
コンパイル使用メモリ 245,084 KB
実行使用メモリ 13,636 KB
最終ジャッジ日時 2024-11-26 12:16:42
合計ジャッジ時間 6,740 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...)
#endif

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) ans += abs(i - j) * abs(A[i] - A[j]);
    }

    cout << ans << '\n';
}
0