/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 77ms 5.332 MiB
#2 Accepted 859ms 5.086 MiB
#3 Accepted 864ms 4.914 MiB
#4 Accepted 1496ms 5.094 MiB
#5 Accepted 1128ms 4.977 MiB
#6 Accepted 851ms 5.125 MiB
#7 Accepted 857ms 4.934 MiB
#8 Accepted 854ms 4.891 MiB
#9 Accepted 903ms 5.066 MiB
#10 Accepted 834ms 4.934 MiB
#11 Accepted 856ms 4.988 MiB
#12 Accepted 788ms 5.035 MiB
#13 Accepted 307ms 5.098 MiB

Code

#include <bits/stdc++.h>

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

    int n;
    std::cin >> n;
    std::vector<int> ans(n);
    std::unordered_map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        int x;
        std::cin >> x;
        cnt[x]++;
    }
    for (int i = 1; i <= n; i++) {
        for (int g = 1; g <= 100000; g++) {
            int c = 0;
            for (int mul = 0; mul <= 100000; mul += g) {
                c += cnt[mul];
            }
            if (c >= i && c != cnt[0]) {
                ans[i - 1] = std::max(ans[i - 1], g);
            }
        }
    }
    for (int i = 0; i < n; i++) {
        std::cout << ans[i] << " \n"[i == n - 1];
    }
}

Information

Submit By
Type
Submission
Problem
P1151 Max gcd group
Contest
Happy New Year 2025
Language
C++17 (G++ 13.2.0)
Submit At
2025-01-02 14:50:07
Judged At
2025-01-02 14:50:07
Judged By
Score
100
Total Time
1496ms
Peak Memory
5.332 MiB