/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Time Exceeded ≥1099ms ≥584.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fo(i,a,n) for(ll i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define fi first
#define sc second
#define endl '\n'
#define gcd(x, y)   (__gcd(x, y))
#define lcm(x, y)   ((x/gcd(x, y))*y)
#define mem(a,b) memset(a, b, sizeof(a))
#define de(x) cerr<<#x<<" :: "<<x<<" "<<endl

bool cmp (pair<int,int>a,pair<int,int>b) {
    if(a.second == b.second) {
        return a.first>b.first;
    }
    return a.second<b.second;
}


void solve()
{
  int n;
  cin>>n;
  vector<int>v(n);
  vector<pair<int,int>>v1(n);
  for(int i =0;i<n;i++){
    cin>>v[i];
    v1[i].first=v[i];
  }
  int k;
  cin>>k;
  for(int i =0;i<n;i++){
    int cnt=0;
    for(int j =1;j<=v[i];j++){
        if(v[i]%j==0)cnt++;
    }
    v1[i].second=cnt;
    cnt=0;
  }
    sort(all(v1),cmp);
    cout<<v1[k-1].first<<endl;
}

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int t=1;
    cin>>t;
    while(t--)
    {
        solve();
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1008 Ordering Number
Language
C++17 (G++ 13.2.0)
Submit At
2023-11-29 21:52:36
Judged At
2024-11-11 03:50:04
Judged By
Score
0
Total Time
≥1099ms
Peak Memory
≥584.0 KiB