/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 532.0 KiB
#2 Accepted 4ms 532.0 KiB
#3 Wrong Answer 27ms 444.0 KiB
#4 Wrong Answer 25ms 324.0 KiB
#5 Wrong Answer 27ms 560.0 KiB
#6 Wrong Answer 26ms 320.0 KiB
#7 Wrong Answer 28ms 324.0 KiB
#8 Wrong Answer 44ms 560.0 KiB
#9 Wrong Answer 62ms 552.0 KiB
#10 Accepted 123ms 564.0 KiB
#11 Accepted 455ms 560.0 KiB
#12 Wrong Answer 439ms 560.0 KiB
#13 Wrong Answer 210ms 556.0 KiB
#14 Wrong Answer 222ms 564.0 KiB
#15 Wrong Answer 230ms 564.0 KiB
#16 Accepted 248ms 564.0 KiB
#17 Wrong Answer 211ms 560.0 KiB
#18 Wrong Answer 259ms 568.0 KiB
#19 Wrong Answer 221ms 564.0 KiB

Code

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

#define all(v) v.begin(), v.end()

using LL = long long;

const int N = 101;

int main() {
  cin.tie (nullptr) -> ios_base :: sync_with_stdio (false);

  int tests;
  cin >> tests;
  while (tests--) {
    int n;
    cin >> n;
    vector <int> v (n);
    for (auto &i : v) cin >> i;
    int even = n / 2, odd = n - even, ans = 0;
    for (int i = 1; i <= N; i++) {
      for (int j = i; j <= N; j++) {
        int both = 0, left = 0, right = 0;
        for (int k = 0; k < n; k++) {
          if (v[k] % (i * j) == 0) both++;
          else if (v[k] % i == 0) left++;
          else if (v[k] % j == 0) right++;
        }
        if (left > right) swap (left, right);
        if (both >= max (0, even - left) + max (0, odd - right)) ans = max (ans, i + j);
      }
    }
    cout << ans << '\n';
  }

  return 0;
}

Information

Submit By
Type
Submission
Problem
P1076 Even Odd GCD (Easy Version)
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-16 19:58:51
Judged At
2024-10-03 13:20:00
Judged By
Score
33
Total Time
455ms
Peak Memory
568.0 KiB