結果
| 問題 |
No.1233 割り切れない気持ち
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-04 16:51:10 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 612 bytes |
| コンパイル時間 | 1,797 ms |
| コンパイル使用メモリ | 197,400 KB |
| 最終ジャッジ日時 | 2025-01-15 02:43:46 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 36 TLE * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | int n; scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:11:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | rep(i,n) scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#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;
}