답안 #844269

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844269 2023-09-05T11:56:47 Z vjudge1 Spiderman (COCI20_spiderman) C++17
28 / 70
2000 ms 8936 KB
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int int64_t
#define ordered_set                              \
    tree<int, null_type, less<int>, rb_tree_tag, \
         tree_order_statistics_node_update>
#define F first
#define S second
#define I insert
#define PB push_back
#define POB pop_back
#define sqr(a) ((a) * (a))
#define P pop
#define max3(a, b, c) (max(a, max(b, c)))
#define max4(a, b, c, d) (max(max(a, b), max(c, d)))
#define min3(a, b, c) (min(a, min(b, c)))
#define min4(a, b, c, d) (min(min(a, b), min(c, d)))
#define MOD 1000000007
#define mod 998244353
int binpow(int a, int p, int m = MOD) {
    int ans = 1;
    while (p) {
        if (p & 1) ans = ((ans % m) * (a % m)) % m;
        a = sqr(a) % m;
        p >>= 1;
    }
    return ans;
}
void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n, 0);
    map<int, int> heights, ans;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        heights[h[i]]++;
    }
    for (auto x : heights) {
        for (auto y : heights) {
            if (y.F == x.F) continue;
            if (x.F % y.F == k) ans[x.F] += y.S;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << ans[h[i]];
        if (i != n - 1) cout << ' ';
    }
}
int32_t main() {
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 620 KB Output is correct
2 Correct 7 ms 344 KB Output is correct
3 Correct 61 ms 1560 KB Output is correct
4 Correct 140 ms 3884 KB Output is correct
5 Execution timed out 2089 ms 7728 KB Time limit exceeded
6 Execution timed out 2032 ms 8700 KB Time limit exceeded
7 Execution timed out 2045 ms 7976 KB Time limit exceeded
8 Execution timed out 2033 ms 7504 KB Time limit exceeded
9 Execution timed out 2037 ms 8272 KB Time limit exceeded
10 Execution timed out 2017 ms 8936 KB Time limit exceeded