답안 #844297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844297 2023-09-05T12:08:09 Z vjudge1 Spiderman (COCI20_spiderman) C++17
56 / 70
144 ms 10584 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  map<int, int> cnt;
  for (int i = 0;i < N; ++i) {
    cin >> h[i];
    cnt[h[i]] += 1;
  }
  int MAX_H = 1e6 + 37;
  vector<int> div_cnt(MAX_H);
  for (auto [i, num] : cnt) {
    if (i <= K) {
      continue;
    }
    for (int j = 0;i * j < MAX_H; ++j) {
      div_cnt[i * j] += num;
    } 
  }
  int64_t ans = 0;
  for (int i = 0;i < N; ++i) {
    if (h[i] - K < 0) {
      cout << 0 << ' ';
      continue;
    }
    cout << (div_cnt[h[i] - K]) << ' ';
  }
}

Compilation message

spiderman.cpp: In function 'int main()':
spiderman.cpp:22:11: warning: unused variable 'ans' [-Wunused-variable]
   22 |   int64_t ans = 0;
      |           ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4252 KB Output is correct
2 Correct 5 ms 4320 KB Output is correct
3 Correct 34 ms 4996 KB Output is correct
4 Correct 95 ms 6528 KB Output is correct
5 Incorrect 68 ms 9552 KB Output isn't correct
6 Incorrect 143 ms 10584 KB Output isn't correct
7 Correct 70 ms 9556 KB Output is correct
8 Correct 75 ms 9556 KB Output is correct
9 Correct 144 ms 10320 KB Output is correct
10 Correct 144 ms 10324 KB Output is correct