답안 #868762

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
868762 2023-11-02T01:08:03 Z Pring Spiderman (COCI20_spiderman) C++14
70 / 70
63 ms 27088 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define fs first
#define sc second
#define mp make_pair
typedef pair<int, int> pii;
typedef pair<pii, int> p3i;

const int MXN = 300005, MXM = 1000005;
int n, k, a[MXN], c[MXM], p[MXM], d[MXM];

void miku() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        c[a[i]]++;
    }
    for (int i = 0; i < MXM - 1; i++) p[i + 1] = p[i] + c[i];
    for (int i = k + 1; i < MXM; i++) {
        for (int j = 0; j < MXM; j += i) {
            d[j] += c[i];
        }
    }
    for (int i = 0; i < n; i++) {
        if (a[i] < k) cout << 0 << ' ';
        else if (a[i] == k) cout << p[MXM - 1] - p[a[i] + 1] << ' ';
        else {
            if (k == 0) cout << d[a[i]] - 1 << ' ';
            else cout << d[a[i] - k] << ' ';
        }
    }
    cout << endl;
}

int32_t main() {
    cin.tie(0) -> sync_with_stdio(false);
    miku();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 25180 KB Output is correct
2 Correct 15 ms 25176 KB Output is correct
3 Correct 28 ms 25396 KB Output is correct
4 Correct 63 ms 27088 KB Output is correct
5 Correct 28 ms 25436 KB Output is correct
6 Correct 54 ms 26964 KB Output is correct
7 Correct 26 ms 25428 KB Output is correct
8 Correct 27 ms 25436 KB Output is correct
9 Correct 53 ms 26800 KB Output is correct
10 Correct 53 ms 26968 KB Output is correct