結果

問題 No.2938 Sigma Sigma Distance Distance Problem
ユーザー karinohito
提出日時 2024-10-19 00:02:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 345 bytes
コンパイル時間 2,350 ms
コンパイル使用メモリ 195,784 KB
最終ジャッジ日時 2025-02-24 21:21:48
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll N;
    cin>>N;
    assert(N<=100);
    vector<ll> A(N);
    ll an=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
        for(int j=0;j<i;j++)an+=abs(i-j)*abs(A[i]-A[j])*2;
    }
    cout<<an<<endl;
}
0