답안 #844395

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844395 2023-09-05T12:55:19 Z vjudge1 Spiderman (COCI20_spiderman) C++17
21 / 70
2000 ms 113204 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) continue;
        for(int i=p.st+k; i<=maxi; i+=p.st){
            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();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 923 ms 99140 KB Output is correct
2 Correct 1063 ms 108596 KB Output is correct
3 Execution timed out 2028 ms 75760 KB Time limit exceeded
4 Correct 1514 ms 113204 KB Output is correct
5 Execution timed out 2068 ms 70248 KB Time limit exceeded
6 Execution timed out 2067 ms 70996 KB Time limit exceeded
7 Execution timed out 2051 ms 44968 KB Time limit exceeded
8 Execution timed out 2071 ms 53588 KB Time limit exceeded
9 Execution timed out 2096 ms 62392 KB Time limit exceeded
10 Execution timed out 2029 ms 57520 KB Time limit exceeded