結果
| 問題 | No.3470 実行時間の差の合計 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-11 00:32:03 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 41 ms / 2,000 ms |
| コード長 | 402 bytes |
| 記録 | |
| コンパイル時間 | 3,328 ms |
| コンパイル使用メモリ | 340,712 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2026-03-11 00:32:08 |
| 合計ジャッジ時間 | 5,385 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_1 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| sample | 0 % | AC * 3 |
| small | 40 % | AC * 7 |
| large | 30 % | AC * 8 |
| ランダムlarge | 30 % | AC * 10 |
| 合計 | 100 点 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i)
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int N;
cin >> N;
vector<ll> T(N);
rep(i, 0, N) cin >> T[i];
sort(T.begin(), T.end());
ll ans = 0;
ll sum = 0;
rep(i, 0, N) {
ans += T[i]*i - sum;
sum += T[i];
}
cout << ans << '\n';
}