Submission #1335474

#TimeUsernameProblemLanguageResultExecution timeMemory
1335474killerzaluuSequence (APIO23_sequence)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
  int n, i, j;
  cin >> n;

  int a[n + 1];
  for(i = 1; i <= n; i++) cin >> a[i];

  int ans = 0;

  for(i = 1; i <= n; i++) {
    ordered_set<pair<int,int>> sad;
    int freq[n + 1];
    for(int k = 1; k <= n; k++) freq[k] = 0;

    for(j = i; j <= n; j++) {
      sad.insert({a[j], j});
      freq[a[j]]++;

      int len = j - i + 1;

      auto L = *sad.find_by_order((len - 1) / 2);
      auto R = *sad.find_by_order(len / 2);

      int x = L.first;
      int y = R.first;

      ans = max(ans, max(freq[x], freq[y]));
    }
  }

  cout << ans << endl;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccxyMcKK.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccw1YLWn.o:sequence.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccxyMcKK.o: in function `main':
grader.cpp:(.text.startup+0x283): undefined reference to `sequence(int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status