Submission #844347

# Submission time Handle Problem Language Result Execution time Memory
844347 2023-09-05T12:29:07 Z vjudge1 Spiderman (COCI20_spiderman) C++14
14 / 70
1112 ms 16208 KB
// Aber der schlimmste Fiend, dem du begegnen kannst, wirst du immer dir selber sein
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
#define int long long int
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define rev reverse
#define all(x) x.begin(),x.end()
#define acc accumulate
#define sz size()
#define MOD 1000000007
#define rall(x) x.rbegin(),x.rend()
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const int N = 1e6 + 5;
int cnt[N];
inline void solve(){
    int n, k;
    cin >> n >> k;
    pair<int, int> a[n];
    rep(i, 0, n) cin >> a[i].ff;
    rep(i, 0, n) a[i].ss = i;
    int ans[n];
    sort(a, a+n);
    rev(a, a+n);
    rep(i, 0, n){
        cnt[a[i].ff]++;
    }
    rep(i, 0, n){
        ans[a[i].ss] = 0;
        if(a[i].ff == k){
            ans[a[i].ss] = i;
        }
        a[i].ff -= k;
        vector<int> v;
        for(int j = 1; j <= sqrt(a[i].ff); j++){
            if(a[i].ff % j == 0){
                v.pb(j);
                if(j != (a[i].ff/j)) v.pb(a[i].ff / j);
            }
        }
        cnt[a[i].ff] --;
        for(int j : v) {
            if(j <= k) continue;
            ans[a[i].ss] += cnt[j];
        }
        cnt[a[i].ff]++;
    }
    rep(i, 0, n) cout << ans[i] << " ";
    cout << endl;
}
int32_t main(){
    fast_io
    int t;
    t = 1;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 7256 KB Output isn't correct
2 Incorrect 6 ms 7000 KB Output isn't correct
3 Incorrect 287 ms 9976 KB Output isn't correct
4 Incorrect 854 ms 15440 KB Output isn't correct
5 Correct 335 ms 10832 KB Output is correct
6 Correct 980 ms 16208 KB Output is correct
7 Incorrect 387 ms 10612 KB Output isn't correct
8 Incorrect 375 ms 10832 KB Output isn't correct
9 Incorrect 1112 ms 16144 KB Output isn't correct
10 Incorrect 1110 ms 16076 KB Output isn't correct