Wrong Answer
Code
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
int t;
cin >> t;
while (t--){
ll n, a, x, cur = 0, ans = 1, mx = 0;
cin >> n >> x;
//vector<ll> a(n);
map<ll, ll> mp;
for (int i = 0; i < n; i++){
cin >> a;
cur += a;
mp[a] += a;
mx = max(mx, a);
}
for (int i = 2; i <= min(mx + 1, x); i++){
ll cnt = 0;
for (int j = i; j <= min(mx + 1, x); j += i){
cnt += mp[j];
}
if (cnt < cur){
cur = cnt, ans = i;
}
}
cout << ans << endl;
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1039 Prince Roy, the undisputed ruler of the world
- Contest
- Brain Booster #3
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-05-06 17:47:56
- Judged At
- 2024-11-11 03:31:51
- Judged By
- Score
- 50
- Total Time
- 72ms
- Peak Memory
- 1.125 MiB