結果
問題 | No.2938 Sigma Sigma Distance Distance Problem |
ユーザー |
|
提出日時 | 2024-10-18 21:24:17 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 986 bytes |
コンパイル時間 | 3,274 ms |
コンパイル使用メモリ | 274,908 KB |
実行使用メモリ | 13,644 KB |
最終ジャッジ日時 | 2024-10-18 21:47:47 |
合計ジャッジ時間 | 64,935 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 TLE * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(ll i=0;i<(ll)n;i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define mod 998244353 #define dai 5000000000000000000LL #define sho -dai #define eps 1e-14 #define fi(x) cout<<fixed<<setprecision(x); using ll=long long; using un=unsigned long long; using ld=long double; using st=string; using ch=char; using bo=bool; using P=pair<ll,ll>; using T=tuple<ll,ll,ll>; using vi=vector<ll>; using vs=vector<st>; using vc=vector<ch>; using vb=vector<bo>; using vp=vector<P>; using sp=set<P>; using ss=set<st>; using si=set<ll>; using vvi=vector<vi>; using vvs=vector<vs>; using vvb=vector<vb>; using vvc=vector<vc>; using vvp=vector<vp>; using vsi=vector<set<ll>>; const ll dx[4]={0,1,0,-1}; const ll dy[4]={1,0,-1,0}; const ll INF = 1e18; int main() { ll n; cin>>n; vi a(n); rep(i,n){ cin>>a[i]; } ll ans=0; rep(i,n){ rep(j,n){ ans+=abs(i-j)*abs(a[i]-a[j]); } } cout<<ans<<endl; }