/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 13ms 4.359 MiB
#2 Accepted 16ms 4.363 MiB
#3 Wrong Answer 17ms 4.363 MiB
#4 Accepted 17ms 4.367 MiB
#5 Wrong Answer 18ms 4.367 MiB
#6 Accepted 18ms 4.367 MiB
#7 Accepted 19ms 4.363 MiB
#8 Accepted 28ms 4.359 MiB
#9 Accepted 30ms 4.359 MiB
#10 Accepted 31ms 4.363 MiB
#11 Accepted 33ms 4.363 MiB
#12 Accepted 32ms 4.207 MiB
#13 Accepted 23ms 4.363 MiB
#14 Accepted 39ms 4.367 MiB
#15 Accepted 46ms 4.363 MiB
#16 Accepted 56ms 4.367 MiB
#17 Accepted 341ms 4.367 MiB
#18 Accepted 2942ms 4.363 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-10-03 13:50:33
Judged By
Score
75
Total Time
2942ms
Peak Memory
4.367 MiB