# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
890252 | HADI_T | Spiderman (COCI20_spiderman) | C++14 | 1043 ms | 15696 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define int long long
#define pb(x) push_back(x)
#define in(x) insert(x)
#define F first
#define S second
#define endl '\n'
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
const int M=1e9+7;
const int N=1e6+10;
using namespace std;
int freq[N];
int32_t main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,c;
cin>>n>>c;
int a[n+10] , ans[n+10]={0};
for(int i=1;i<=n;i++){
cin>>a[i];
freq[a[i]]++;
}
for(int i=1;i<=n;i++)
{
int cur = a[i] - c;
for(int j=1;j*j<=cur;j++)
{
if(cur % j == 0)
{
int f = j , s = cur/j;
if(cur + f > a[i])
ans[i] += freq[f];
if(cur + s > a[i]){
if(f != s)
ans[i] += freq[s];
}
}
}
}
sort(a+1,a+1+n);
int idx = n;
for(int i=n;i>=1;i--)
{
if(a[i] == c)
{
idx = i;
break;
}
}
for(int i=1;i<=n;i++){
if(a[i] == c)
ans[i] += n-idx;
cout<<ans[i]<<' ';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |