Submission #500263

# Submission time Handle Problem Language Result Execution time Memory
500263 2021-12-30T14:36:50 Z Mounir Spiderman (COCI20_spiderman) C++14
70 / 70
380 ms 24772 KB
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define pb push_back
#define pii pair<int, int>
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
#define x first
#define y second
#define int long long
using namespace std;

const int N = 2e6 + 1;
int nDiv[N];

signed main(){
      int nVals, k; cin >> nVals >> k;
      vector<int> vals(nVals);
      map<int, int> occs;
      for (int& val : vals){
            cin >> val;
            if (val > k)
                  occs[val]++;
      }

      for (auto paire : occs){
            int val = paire.first, nOccs = paire.second;
            for (int j = 0; j < N; j += val){
                  nDiv[j] += nOccs;
                  if (j == val && k == 0)
                        nDiv[j]--;
            }
      }

      for (int val : vals){
            if (val < k)
                  cout << 0 << " ";
            else
                  cout << nDiv[val - k] << " ";
      }
      cout << endl;
      return 0;   
}
# Verdict Execution time Memory Grader output
1 Correct 42 ms 16076 KB Output is correct
2 Correct 48 ms 16000 KB Output is correct
3 Correct 102 ms 17064 KB Output is correct
4 Correct 166 ms 19372 KB Output is correct
5 Correct 223 ms 23196 KB Output is correct
6 Correct 380 ms 24772 KB Output is correct
7 Correct 198 ms 23096 KB Output is correct
8 Correct 252 ms 23164 KB Output is correct
9 Correct 322 ms 24584 KB Output is correct
10 Correct 344 ms 24672 KB Output is correct