Submission #844500

# Submission time Handle Problem Language Result Execution time Memory
844500 2023-09-05T13:39:26 Z vjudge1 Spiderman (COCI20_spiderman) C++17
56 / 70
751 ms 24860 KB
#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define spc << " " <<
#define all(x) x.begin(), x.end()
#define ll long long
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 1000000007

using namespace std;




void solve(){
    int n,k; cin >> n >> k;
    int arr[n+1];
    map<int, int> num;
    map<int, int> ans;
    int fork=0;
    for(int i=1; i<=n; i++){
        cin >> arr[i];
        if(arr[i]>k){
            num[arr[i]]++;
            fork++;
        }
    }
    ans[k]=fork;
    for(auto p:num){
        int div=p.st-k;
        for(int i=1; i*i<=div; i++){
            if(i*i==div) ans[p.st]+= num[i];
            else if(div%i==0){
                ans[p.st]+= num[div/i] + num[i];
            }
        }
    }
    for(int i=1; i<=n; i++) cout << ans[arr[i]] << " ";
}



signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    #ifdef Local
    freopen("in.txt","r",stdin);
    freopen("out","w",stdout);
    #endif
    

    ll t=1;
    //cin >> t;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1112 KB Output is correct
2 Correct 5 ms 856 KB Output is correct
3 Correct 30 ms 2132 KB Output is correct
4 Correct 73 ms 4540 KB Output is correct
5 Incorrect 573 ms 17232 KB Output isn't correct
6 Incorrect 661 ms 18192 KB Output isn't correct
7 Correct 674 ms 23200 KB Output is correct
8 Correct 715 ms 23340 KB Output is correct
9 Correct 751 ms 24860 KB Output is correct
10 Correct 676 ms 24624 KB Output is correct