結果
| 問題 | No.3470 実行時間の差の合計 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-07 00:04:08 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 2,000 ms |
| コード長 | 398 bytes |
| 記録 | |
| コンパイル時間 | 2,901 ms |
| コンパイル使用メモリ | 217,844 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2026-03-07 00:04:13 |
| 合計ジャッジ時間 | 3,686 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| sample | 0 点 | AC * 3 |
| small | 40 点 | AC * 7 |
| large | 30 点 | AC * 8 |
| ランダムlarge | 30 点 | AC * 10 |
| 合計 | 100 点 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N; cin >> N;
vector<int> A(N);
for(auto &a : A) cin >> a;
sort(A.begin(),A.end());
long long answer = 0,sum = 0;
for(int i=0; i<N; i++){
long long a = A.at(i);
answer += a*i-sum;
sum += a;
}
cout << answer << endl;
}