#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define pb push_back
#define pii pair<int, int>
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
#define x first
#define y second
#define int long long
using namespace std;
const int N = 2e6 + 1;
int nDiv[N];
signed main(){
int nVals, k; cin >> nVals >> k;
vector<int> vals(nVals);
map<int, int> occs;
for (int& val : vals){
cin >> val;
if (val > k)
occs[val]++;
}
for (auto paire : occs){
int val = paire.first, nOccs = paire.second;
for (int j = 0; j < N; j += val)
nDiv[j] += nOccs;
}
for (int val : vals){
if (val < k)
cout << 0 << " ";
else
cout << nDiv[val - k] << " ";
}
cout << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
43 ms |
16076 KB |
Output is correct |
2 |
Correct |
46 ms |
16012 KB |
Output is correct |
3 |
Correct |
99 ms |
17180 KB |
Output is correct |
4 |
Correct |
158 ms |
19396 KB |
Output is correct |
5 |
Incorrect |
223 ms |
23116 KB |
Output isn't correct |
6 |
Incorrect |
327 ms |
24936 KB |
Output isn't correct |
7 |
Correct |
183 ms |
23092 KB |
Output is correct |
8 |
Correct |
180 ms |
23112 KB |
Output is correct |
9 |
Correct |
301 ms |
24708 KB |
Output is correct |
10 |
Correct |
348 ms |
24624 KB |
Output is correct |