結果
問題 | No.2938 Sigma Sigma Distance Distance Problem |
ユーザー |
|
提出日時 | 2024-10-18 23:01:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 478 bytes |
コンパイル時間 | 2,106 ms |
コンパイル使用メモリ | 192,572 KB |
最終ジャッジ日時 | 2025-02-24 21:11:07 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 2 WA * 18 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;ll A[555], B[555];int main () {int N;cin >> N;fill(A, A + 505, 0ll);fill(B, B + 505, 0ll);ll ans = 0;for (int i = 0; i < N; i ++) {ll a;cin >> a;ll p = 0, q = 0;for (ll x = 0; x < a; x ++) {p += A[x];q += B[x];ans += i * p + q;}for (ll x = 502; x > a; x --) {p += A[x];q += B[x];ans += i * p + q;}A[a] ++;B[a] -= i;}cout << ans * 2 << endl;}