Submission #844260

# Submission time Handle Problem Language Result Execution time Memory
844260 2023-09-05T11:54:54 Z vjudge1 Spiderman (COCI20_spiderman) C++17
7 / 70
1247 ms 24340 KB
#include <bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define int long long
using namespace std;

const int inf = 2e18 + 5;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;

int32_t main(){
  //freopen("in.txt","r", stdin);
  vector<int> abul(N, 1), prime;
  for(int i = 2; i < N; i++){
    if(abul[i] == 1){
        prime.pb(i);
        for(int j = i*2; j < N; j += i) abul[j] = 0;
    }
  }
  int n, k;
  cin>>n>>k;
  vector<pair<int, int> > h(n);
  for(int i = 0; i < n; i++){
    cin>>h[i].first;
    h[i].second = i;
  }
  sort(h.begin(), h.end());
  vector<int> ans(n);
  map<int, int> mp;

  for(int i = 0; i < n; i++){
    if(h[i].first < k){
        ans[h[i].second] = 0;
    }
    else if(h[i].first == k){
        ans[h[i].second] = (n - i - 1);
    }
    else{
        int x = h[i].first - k, cnt = 0;

        for(int j = k+1; j * j <= x; j++){
            if(x%j == 0){
                cnt += mp[x/j];
                //if(h[i].first == 5) cout<<x/j<<" "<<mp[x/j]<<endl;
                if(j != x/j){
                    cnt += mp[j];
                    //if(h[i].first == 5) cout<<x/j<<" "<<mp[x/j]<<endl;
                }
            }
        }
        if(x > k) cnt += mp[x];

        ans[h[i].second] = cnt;
    }
    mp[h[i].first]++;
  }

  for(int i = 0; i < n; i++){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 2516 KB Output isn't correct
2 Incorrect 8 ms 2520 KB Output isn't correct
3 Incorrect 294 ms 5324 KB Output isn't correct
4 Incorrect 847 ms 10700 KB Output isn't correct
5 Correct 479 ms 14708 KB Output is correct
6 Incorrect 1144 ms 18984 KB Output isn't correct
7 Incorrect 375 ms 14764 KB Output isn't correct
8 Incorrect 459 ms 16076 KB Output isn't correct
9 Incorrect 1247 ms 24340 KB Output isn't correct
10 Incorrect 1188 ms 22240 KB Output isn't correct