답안 #565385

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
565385 2022-05-20T20:29:47 Z faruk Spiderman (COCI20_spiderman) C++17
70 / 70
136 ms 10520 KB
#include <bits/stdc++.h>
#define pii pair<int, int>
#define ll long long
#define ld long double

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    vector<int> mark(1e6 + 1, 0);
    map<int, int> histo;
    vector<int> arr;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        histo[x]++;
        arr.push_back(x);
    }

    for (pii x : histo) {
        if (x.first < k || x.first == k)
            continue;
        for (int i = k; i <= 1e6; i += x.first)
            mark[i] += x.second;
    }

    for (int i = 0; i < n - 1; i++)
    {
        if (k == 0)
            cout << mark[arr[i]] - 1 <<" ";
        else
            cout << mark[arr[i]] << " ";
    }

    if (k == 0)
        cout << mark[arr[n - 1]] - 1 << "\n";
    else
        cout << mark[arr[n - 1]] << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4308 KB Output is correct
2 Correct 5 ms 4180 KB Output is correct
3 Correct 28 ms 5108 KB Output is correct
4 Correct 66 ms 6488 KB Output is correct
5 Correct 63 ms 9516 KB Output is correct
6 Correct 127 ms 10520 KB Output is correct
7 Correct 63 ms 9432 KB Output is correct
8 Correct 67 ms 9464 KB Output is correct
9 Correct 136 ms 10364 KB Output is correct
10 Correct 125 ms 10320 KB Output is correct