結果
問題 |
No.1233 割り切れない気持ち
|
ユーザー |
![]() |
提出日時 | 2025-08-15 15:20:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 793 bytes |
コンパイル時間 | 2,167 ms |
コンパイル使用メモリ | 193,816 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2025-08-15 15:20:51 |
合計ジャッジ時間 | 7,483 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 5 TLE * 1 -- * 33 |
ソースコード
#include<bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, a[N], p = 0, pos[N]; long long ans, sum[N]; int main(){ ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); // freopen("samples2.in", "r", stdin); // freopen("sample.ans", "w", stdout); // cout << log2(200000); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; } sort(a + 1, a + 1 + n); pos[n] = n + 1; for(int i = n; i >= 2; i--){ if(a[i - 1] != a[i]){ pos[i - 1] = i; } else{ pos[i - 1] = pos[i]; } } for(int i = 1; i <= n; i++){ for(int j = pos[i]; j <= n; j++){ ans += a[j] % a[i]; } ans += sum[p]; if(a[i] != a[i + 1]){ p = i; } sum[i] = sum[i - 1] + a[i]; //cout << sum[i] << " "; } cout << ans; return 0; }