/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 320.0 KiB
#2 Time Exceeded ≥2091ms ≥620.0 KiB
#3 Time Exceeded ≥2079ms ≥548.0 KiB
#4 Time Exceeded ≥2076ms ≥576.0 KiB
#5 Time Exceeded ≥2072ms ≥788.0 KiB
#6 Time Exceeded ≥2081ms ≥3.523 MiB
#7 Time Exceeded ≥2085ms ≥3.566 MiB
#8 Time Exceeded ≥2091ms ≥3.562 MiB
#9 Time Exceeded ≥2078ms ≥3.566 MiB
#10 Time Exceeded ≥2087ms ≥3.426 MiB
#11 Time Exceeded ≥2085ms ≥3.566 MiB
#12 Time Exceeded ≥2084ms ≥3.566 MiB
#13 Time Exceeded ≥2074ms ≥3.375 MiB
#14 Time Exceeded ≥2088ms ≥3.562 MiB
#15 Time Exceeded ≥2092ms ≥3.539 MiB
#16 Time Exceeded ≥2083ms ≥3.578 MiB
#17 Time Exceeded ≥2087ms ≥1.316 MiB
#18 Time Exceeded ≥2087ms ≥532.0 KiB
#19 Time Exceeded ≥2089ms ≥532.0 KiB
#20 Time Exceeded ≥2080ms ≥3.512 MiB

Code

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using ll = long long;

const ll MOD = 4;

mt19937 R(chrono::steady_clock::now().time_since_epoch().count());

template<typename T>
vector<T> normalize(vector<T>& a, T start = 0) {
  int n = a.size();
  vector<T> b = a;
  sort(b.begin(), b.end());
  b.erase(unique(b.begin(), b.end()), b.end());
  vector<T> ret(n, start);
  for (int i = 0; i < n; ++i) {
    ret[i] += lower_bound(b.begin(), b.end(), a[i]) - b.begin();
  }
  return ret;
}

int main() {
  FAST;
  
  int tc = 1, ti;
  cin >> tc;

  for (ti = 1; ti <= tc; ++ti) {
    ll n, i, j, t, curr, ans;
    cin >> n;

    vector<ll> a(n), col(n);
    for (i = 0; i < n; ++i) cin >> a[i];

    ans = LLONG_MAX;
    t = n*100; while (t--) {
      col[0] = R() % MOD;
      col[1] = R() % MOD;
      while (col[1] == col[0]) col[1] = R() % MOD;
      vector<int> ind;
      for (i = 0; i < MOD; ++i) {
        if (i == col[0]) continue;
        if (i == col[1]) continue;
        ind.push_back(i);
      }
      for (i = 2; i < n; ++i) {
        j = R() % (MOD-2);
        col[i] = ind[j];
        ind[j] = col[i-2];
      }
      curr = 0;
      for (i = 0; i < n; ++i) curr += col[i] * a[i];
      ans = min(ans, curr);
    }

    cout << ans << "\n";
  }

  return 0;
}

Information

Submit By
Type
Submission
Problem
P1087 Face the monsters
Contest
Brain Booster #5
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-05 17:43:53
Judged At
2024-10-03 13:02:52
Judged By
Score
5
Total Time
≥2092ms
Peak Memory
≥3.578 MiB