Submission #922354

# Submission time Handle Problem Language Result Execution time Memory
922354 2024-02-05T12:32:21 Z Shayan86 Spiderman (COCI20_spiderman) C++14
70 / 70
63 ms 21788 KB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// Ofast, O0, O1, O2, O3, unroll-loops, fast-math, trapv

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define Mp          make_pair
#define sep         ' '
#define endl        '\n'
#define F	        first
#define S	        second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define kill(res)	cout << res << '\n', exit(0);
#define set_dec(x)	cout << fixed << setprecision(x);
#define fast_io     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io     freopen("input.txt", "r", stdin) ; freopen("output.txt", "w", stdout);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll N = 1e6 + 50;
const ll Mod = 1e9 + 7;

ll n, k, arr[N], cnt[N], sum[N];

int main(){
    fast_io;

    cin >> n >> k;

    for(int i = 1; i <= n; i++){
        cin >> arr[i]; 
        if(arr[i] > k) cnt[arr[i]]++;
    }

    for(int i = N-1; i > 0; i--){
        for(int j = 0; j < N; j += i) sum[j] += cnt[i];
    }

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

}
# Verdict Execution time Memory Grader output
1 Correct 17 ms 16988 KB Output is correct
2 Correct 17 ms 17076 KB Output is correct
3 Correct 29 ms 17880 KB Output is correct
4 Correct 49 ms 21716 KB Output is correct
5 Correct 29 ms 17756 KB Output is correct
6 Correct 63 ms 21788 KB Output is correct
7 Correct 41 ms 18008 KB Output is correct
8 Correct 30 ms 17692 KB Output is correct
9 Correct 54 ms 21588 KB Output is correct
10 Correct 53 ms 21552 KB Output is correct