Submission #844383

# Submission time Handle Problem Language Result Execution time Memory
844383 2023-09-05T12:51:19 Z vjudge1 Spiderman (COCI20_spiderman) C++17
21 / 70
2000 ms 113320 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 maxi=0;
    for(int i=1; i<=n; i++){
        cin >> arr[i];
        num[arr[i]]++;
        if(arr[i]>maxi) maxi=arr[i];
    }
    for(auto p:num){
        if(k%p.st==0) continue;
        for(int i=p.st+k; i<=maxi; i+=p.st){
            if(i%p.st==k) ans[i]+=p.nd;
        }
    }
    for(int i=k+1; i<=maxi; i++){
        if(num[i]>0) ans[k]+=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 960 ms 99292 KB Output is correct
2 Correct 1133 ms 108900 KB Output is correct
3 Execution timed out 2043 ms 77156 KB Time limit exceeded
4 Correct 1576 ms 113320 KB Output is correct
5 Incorrect 239 ms 70228 KB Output isn't correct
6 Incorrect 306 ms 71508 KB Output isn't correct
7 Execution timed out 2043 ms 45300 KB Time limit exceeded
8 Execution timed out 2032 ms 53464 KB Time limit exceeded
9 Execution timed out 2011 ms 62184 KB Time limit exceeded
10 Execution timed out 2086 ms 57264 KB Time limit exceeded