# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
499300 | inksamurai | Spiderman (COCI20_spiderman) | C++17 | 119 ms | 21604 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 fi first
#define se second
#define pb push_back
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define crep(i,x,n) for(ll i=x;i<n;i++)
#define drep(i,n) for(ll i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _3qplfh5 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<ll,ll>;
using vi=vector<ll>;
using vll=vector<long long>;
const ll _n=1e6+10;
int main(){
_3qplfh5;
ll n,k;
cin>>n>>k;
vi a(n);
rep(i,n){
cin>>a[i];
}
ll ma=*max_element(all(a));
vi cnt(_n);
rep(i,n){
cnt[a[i]]++;
}
vi oa=a;
sort(all(a));
a.erase(unique(all(a)),a.end());
vi pans(_n,0);
rep(i,sz(a)){
ll ai=a[i];
ll x=0;
while(x<=_n){
if(x+k<x+ai and x+k<_n){
pans[x+k]+=cnt[ai];
}
x+=ai;
}
}
rep(i,n){
cout<<pans[oa[i]]<<" ";
}
cout<<"\n";
//
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |