# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
849737 | efedmrlr | Spiderman (COCI20_spiderman) | C++17 | 642 ms | 15696 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long int
#define MP make_pair
#define pb push_back
#define REP(i,n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;
const double EPS = 0.00001;
const int INF = 1e9+500;
const int N = 1e6+5;
int n,m,q,k;
vector<int> cnt,h;
vector<int> ans;
void fastio() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
void solve() {
cin>>n>>k;
h.resize(n);
ans.resize(n);
cnt.resize(N,0);
for(int i = 0; i<n; i++) {
cin>>h[i];
}
for(int i = 0; i<n; i++) {
if(h[i] <= k) continue;
int ind = h[i];
while(ind < N) {
cnt[ind]++;
ind+=h[i];
}
}
for(int i = 0; i<n; i++) {
if(h[i] - k < 0) {
ans[i] = 0;
continue;
}
if(h[i] == k) {
ans[i] = -1;
continue;
}
ans[i] = cnt[h[i] - k];
}
sort(h.begin(),h.end());
int ind = 0;
while(ind < n && h[ind] <= k) ind++;
int x = n - ind;
for(int i = 0; i<n; i++) {
if(k==0) ans[i]--;
if(ans[i] == -1) ans[i] = x;
cout<<ans[i]<<" ";
}
}
signed main() {
fastio();
int test = 1;
//cin>>test;
while(test--) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |