Submission #306338

# Submission time Handle Problem Language Result Execution time Memory
306338 2020-09-25T09:11:07 Z syy Watching (JOI13_watching) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))

ll n, p, q, A[2005], w, upper, lower, dp[2005][2005];

ll sandybridge f(ll index, ll bigCamsNeeded) { //Min p that can cover everything
  if (index < 0) return 0;
  if (dp[index][bigCamsNeeded] != -1) return dp[index][bigCamsNeeded]; //If calculated
  dp[index][bigCamsNeeded] = LLONG_MAX;
  if (bigCamsNeeded > 0) {
    ll ind = upper_bound(A, A + n, A[index] - w - w) - A - 1; //Cannot take
    dp[index][bigCamsNeeded] = f(ind, bigCamsNeeded - 1);
  }
  ll ind = upper_bound(A, A + n, A[index] - w) - A - 1;
  dp[index][bigCamsNeeded] = min(dp[index][bigCamsNeeded], f(ind, bigCamsNeeded) + 1); // You used one more small camera so need + 1
  return dp[index][bigCamsNeeded];
}

int sandybridge main() {
    fastio;
  cin >> n >> p >> q;
  if (p + q >= n) {
    cout << 1;
    return 0;
  }
  for (ll i = 0; i < n; i++) cin >> A[i];
  sort(A, A + n);
  lower = 0; upper = A[n - 1] + 1;
  while (upper - lower > 1) {
  memset(dp, -1, sizeof dp); //Not calculated before.
    w = lower + (upper - lower) / 2;
    if (f(n - 1, q) <= p) upper = w;
    else lower = w;
  }
  cout << upper;
}

Compilation message

In file included from /usr/include/features.h:367,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/c++config.h:524,
                 from /usr/include/c++/9/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
                 from watching.cpp:1:
/usr/include/x86_64-linux-gnu/bits/string3.h: In function 'int main()':
/usr/include/x86_64-linux-gnu/bits/string3.h:78:1: error: inlining failed in call to always_inline 'void* memset(void*, int, size_t) noexcept': target specific option mismatch
   78 | __NTH (memset (void *__dest, int __ch, size_t __len))
      | ^~~~~
watching.cpp:33:9: note: called from here
   33 |   memset(dp, -1, sizeof dp); //Not calculated before.
      |   ~~~~~~^~~~~~~~~~~~~~~~~~~