/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 69ms 556.0 KiB
#2 Accepted 452ms 552.0 KiB
#3 Time Exceeded ≥1090ms ≥324.0 KiB
#4 Time Exceeded ≥1092ms ≥320.0 KiB
#5 Time Exceeded ≥1094ms ≥324.0 KiB
#6 Time Exceeded ≥1088ms ≥328.0 KiB
#7 Time Exceeded ≥1087ms ≥324.0 KiB
#8 Time Exceeded ≥1069ms ≥328.0 KiB
#9 Time Exceeded ≥1095ms ≥532.0 KiB
#10 Time Exceeded ≥1094ms ≥532.0 KiB
#11 Time Exceeded ≥1087ms ≥324.0 KiB
#12 Time Exceeded ≥1090ms ≥320.0 KiB
#13 Time Exceeded ≥1080ms ≥560.0 KiB
#14 Time Exceeded ≥1089ms ≥324.0 KiB
#15 Time Exceeded ≥1089ms ≥532.0 KiB
#16 Time Exceeded ≥1081ms ≥320.0 KiB
#17 Time Exceeded ≥1088ms ≥352.0 KiB
#18 Time Exceeded ≥1083ms ≥324.0 KiB
#19 Time Exceeded ≥1052ms ≥324.0 KiB

Code

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

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

using LL = long long;

const int N = 1001;

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 = 1; 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 = min (left + 1, even);
          else if (v[k] % j == 0) right = min (right + 1, odd);
        }
        if (left + right + both == n) 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-17 12:14:29
Judged At
2024-10-03 13:17:33
Judged By
Score
3
Total Time
≥1095ms
Peak Memory
≥560.0 KiB