/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 10ms 612.0 KiB

Code

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
using namespace std;

const int mx = 10003;
vector<int> f(mx, 1);

void calc () {
  for (int i = 2; i < mx; i++) {
    for (int j = i; j < mx; j += i) {
      f[j] += 1;
    }
  }
}

void solve(int cs) {
  int n;
  cin >> n;
  vector<array<int,2>> a(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[i][1] = x;
    a[i][0] = f[x];
  }
  sort(a.begin(), a.end(), [&](auto &i, auto &j){
    if (i[0] == j[0]) {
      return i[1] > j[1];
    } else return i[0] < j[0];
  });
  int k;
  cin >> k;
  cout << a[k - 1][1] << "\n";

}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc = 1; calc();
  cin >> tc;
  for (int cs = 1; cs <= tc; cs++) {
    solve(cs);
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1008 Ordering Number
Language
C++20 (G++ 13.2.0)
Submit At
2024-07-10 18:30:48
Judged At
2024-11-11 03:28:02
Judged By
Score
100
Total Time
10ms
Peak Memory
612.0 KiB