/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 488.0 KiB
#2 Accepted 6ms 332.0 KiB
#3 Wrong Answer 42ms 556.0 KiB
#4 Wrong Answer 38ms 560.0 KiB
#5 Wrong Answer 42ms 552.0 KiB
#6 Wrong Answer 40ms 560.0 KiB
#7 Wrong Answer 42ms 556.0 KiB
#8 Wrong Answer 67ms 552.0 KiB
#9 Wrong Answer 96ms 568.0 KiB
#10 Accepted 185ms 564.0 KiB
#11 Accepted 670ms 560.0 KiB
#12 Wrong Answer 676ms 560.0 KiB
#13 Wrong Answer 330ms 560.0 KiB
#14 Wrong Answer 359ms 560.0 KiB
#15 Wrong Answer 366ms 560.0 KiB
#16 Accepted 359ms 568.0 KiB
#17 Wrong Answer 314ms 560.0 KiB
#18 Wrong Answer 382ms 556.0 KiB
#19 Wrong Answer 335ms 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 20:09:29
Judged At
2024-10-03 13:19:59
Judged By
Score
33
Total Time
676ms
Peak Memory
568.0 KiB