Submission #644546

# Submission time Handle Problem Language Result Execution time Memory
644546 2022-09-24T22:54:57 Z Essa2006 Spiderman (COCI20_spiderman) C++14
70 / 70
799 ms 26632 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define endl '\n'
#define FF first 
#define SS second
#define all(a) a.begin(),a.end()
#define mod (1000000007)
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, k;
    cin>>n>>k;
    map<int, int>mp, inc;
    vector<int>A(n);
    for(int i=0;i<n;i++){
        cin>>A[i];
        mp[A[i]]++;
    }
    int cnt = 0;
    for(auto i = mp.begin();i!=mp.end();i++){
        int num = 0;
        if(i->FF>k)
        cnt+=i->SS , num = i->FF - k;
        if(num){
            for(int j=1;j*j<=num;j++){
                if(num%j==0){
                    if(j>k)
                        inc[num+k]+=mp[j];
                    if(j*j!=num && num/j>k)
                        inc[num+k]+=mp[num/j];
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        if(A[i]==k){
            inc[A[i]]=cnt;
        }
        cout<<inc[A[i]]-(k==0)<<' ';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 980 KB Output is correct
2 Correct 6 ms 724 KB Output is correct
3 Correct 37 ms 2724 KB Output is correct
4 Correct 89 ms 6196 KB Output is correct
5 Correct 689 ms 17832 KB Output is correct
6 Correct 750 ms 19908 KB Output is correct
7 Correct 726 ms 23928 KB Output is correct
8 Correct 770 ms 23904 KB Output is correct
9 Correct 799 ms 26632 KB Output is correct
10 Correct 790 ms 26612 KB Output is correct