/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 10ms 4.359 MiB
#2 Accepted 12ms 4.367 MiB
#3 Wrong Answer 12ms 4.184 MiB

Code

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

#define ll unsigned long long
#define endl '\n'
const int N = 1e6+4;

void solve(int cs){
    int n,x;
    cin>>n>>x;
    int cnt[N] = {0};
    ll s = 0;
    for(int i = 0; i < n; i++){
        int a;cin>>a;
        cnt[a]++;
        s += a;
    }
    int ans = 1;
    
    for(int i = 1; i <= x; i++){
        ll tm = 0;
        for(int j = i; j <= N; j+=i){
            tm += (j*1ll*cnt[j]);
        }
        if(tm < s){
            ans = i;
            s = tm;
        }
    }
    cout<<ans<<endl;
}
   
int main()
{

    ios_base::sync_with_stdio(false);cin.tie(0);
    int t=1,cs=0;
    cin >> t;
    while(t--)
    {
        solve(++cs);
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1039 Prince Roy, the undisputed ruler of the world
Contest
Brain Booster #3
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-06 16:16:46
Judged At
2024-11-11 03:33:15
Judged By
Score
5
Total Time
12ms
Peak Memory
4.367 MiB