結果
| 問題 | No.1233 割り切れない気持ち |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-04 16:51:10 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 612 bytes |
| 記録 | |
| コンパイル時間 | 1,380 ms |
| コンパイル使用メモリ | 213,004 KB |
| 実行使用メモリ | 15,360 KB |
| 最終ジャッジ日時 | 2026-06-14 06:59:26 |
| 合計ジャッジ時間 | 8,196 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 36 TLE * 1 -- * 2 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
int main(){
int n; scanf("%d",&n);
vector<int> a(n);
rep(i,n) scanf("%d",&a[i]);
int amax=*max_element(a.begin(),a.end());
vector<lint> freq(amax+1);
rep(i,n) freq[a[i]]++;
vector<lint> sum1(amax+1),sum2(amax+1);
for(int x=1;x<=amax;x++){
sum1[x]=sum1[x-1]+freq[x];
sum2[x]=sum2[x-1]+x*freq[x];
}
lint ans=0;
for(int y:a){
for(int q=0;q*y<=amax;q++){
int l=q*y,r=min((q+1)*y-1,amax);
ans+=(sum2[r]-sum2[l])-q*y*(sum1[r]-sum1[l]);
}
}
printf("%lld\n",ans);
return 0;
}