結果

問題 No.2938 Sigma Sigma Distance Distance Problem
ユーザー nekoti
提出日時 2024-10-18 21:27:42
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 460 bytes
コンパイル時間 479 ms
コンパイル使用メモリ 30,080 KB
実行使用メモリ 13,644 KB
最終ジャッジ日時 2024-10-18 22:01:24
合計ジャッジ時間 43,066 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 TLE * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _DEBUG 0
#if _DEBUG
#endif

#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<stdlib.h>
int main(void)
{
  int scan;//scanf警告用
  unsigned long long ans=0;
  int i, j;
  
  int n;scan=scanf("%d",&n);
  int a[n];for(i=0; i<n; i++)scan=scanf("%d",&a[i]);
  
  for(i=1; i<=n; i++)
  {
    for(j=1; j<=n; j++)
    {
      unsigned long long tmp=abs(i-j)*abs(a[i-1]-a[j-1]);
      ans+=tmp;
    }
  }
  printf("%llu",ans);
  return 0;
}
0