結果

問題 No.2938 Sigma Sigma Distance Distance Problem
ユーザー kaede2020
提出日時 2024-10-18 21:23:09
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 598 bytes
コンパイル時間 6,036 ms
コンパイル使用メモリ 336,084 KB
実行使用メモリ 13,772 KB
最終ジャッジ日時 2024-10-18 21:43:46
合計ジャッジ時間 67,423 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 TLE * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using mint = modint998244353;

random_device rnd;
mt19937 mt(rnd());
int RandInt(int a, int b) {
    return a + mt() % (b - a + 1);
}

const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i, n) cin>>a[i];
    ll ans=0;
    rep(i,n)rep(j,n){
        ans+=abs(a[i]-a[j])*abs(i-j);
    }
    cout<<ans<<endl;
    return 0;
}
0