/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 324.0 KiB
#2 Accepted 30ms 532.0 KiB
#3 Accepted 31ms 536.0 KiB
#4 Accepted 31ms 536.0 KiB
#5 Accepted 30ms 536.0 KiB
#6 Accepted 55ms 532.0 KiB
#7 Accepted 33ms 528.0 KiB
#8 Accepted 41ms 540.0 KiB
#9 Wrong Answer 53ms 604.0 KiB
#10 Wrong Answer 72ms 1.125 MiB

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