답안 #198977

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
198977 2020-01-28T13:43:33 Z smjleo Spiderman (COCI20_spiderman) C++17
35 / 70
2000 ms 10232 KB
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls int
#define give main()
const int mod = 1000000007;
#pragma endregion
const int N = 300005;

int n, k, ans, arr[N], am[1000005], sc[1000005];

pls give {
    AC;
    cin >> n >> k;
    for (int i=0; i<n; i++) {
        cin >> arr[i];
        am[arr[i]]++;
        sc[arr[i]]++;
        arr[i] -= k;
    }
    for (int i=1; i<1000005; i++) sc[i] += sc[i-1];
    for (int i=0; i<n; i++) {
        ans = 0;
        if (arr[i] == 0) {
            cout << sc[1000004] - sc[arr[i]+k] << ' ';
            continue;
        }

        for (int j=1; j*j<=arr[i]; j++) {
            if (((arr[i]+k)%j == k)) {
                ans += am[j];
            }
            if (j*j == arr[i]) continue;
            if ((arr[i]+k)%(arr[i]/j) == k) {
                ans += am[arr[i]/j];
            }
        }
        cout << ans << ' ';
    }
}

Compilation message

spiderman.cpp:1:0: warning: ignoring #pragma region cp [-Wunknown-pragmas]
 #pragma region cp-helper
 
spiderman.cpp:30:0: warning: ignoring #pragma endregion  [-Wunknown-pragmas]
 #pragma endregion
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 6648 KB Output is correct
2 Correct 29 ms 5624 KB Output is correct
3 Correct 966 ms 7544 KB Output is correct
4 Execution timed out 2040 ms 8696 KB Time limit exceeded
5 Incorrect 1120 ms 8824 KB Output isn't correct
6 Execution timed out 2088 ms 10232 KB Time limit exceeded
7 Correct 1271 ms 8836 KB Output is correct
8 Correct 1274 ms 9208 KB Output is correct
9 Execution timed out 2084 ms 10104 KB Time limit exceeded
10 Execution timed out 2091 ms 9788 KB Time limit exceeded