Submission #1062041

#TimeUsernameProblemLanguageResultExecution timeMemory
1062041KasymKCyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> #define wr puts("----------------") template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} int sequence(int n, vector<int> v){ int answer = 0; unordered_map<int, int> freq; multiset<int> left, right; auto add = [&](int x) { freq[x]++; if (!right.empty() && x >= *right.begin()) { right.insert(x); } else { left.insert(x); } // Balance the left and right sets to maintain equal sizes if (left.size() > right.size() + 1) { right.insert(*left.rbegin()); left.erase(--left.end()); } else if (right.size() > left.size()) { left.insert(*right.begin()); right.erase(right.begin()); } }; auto remove = [&](int x) { if (x >= *right.begin()) { right.erase(right.find(x)); } else { left.erase(left.find(x)); } freq[x]--; if (freq[x] == 0) freq.erase(x); // Rebalance the sets if (left.size() > right.size() + 1) { right.insert(*left.rbegin()); left.erase(--left.end()); } else if (right.size() > left.size()) { left.insert(*right.begin()); right.erase(right.begin()); } }; for (int i = 0; i < n; ++i) { left.clear(); right.clear(); freq.clear(); for (int j = i; j < n; ++j) { add(v[j]); int median1 = *left.rbegin(); int median2 = right.empty() ? median1 : *right.begin(); // Get the maximum frequency of median1 and median2 umax(answer, max(freq[median1], freq[median2])); } } return answer; }

Compilation message (stderr)

cyberland.cpp: In function 'int sequence(int, std::vector<int>)':
cyberland.cpp:35:10: warning: variable 'remove' set but not used [-Wunused-but-set-variable]
   35 |     auto remove = [&](int x) {
      |          ^~~~~~
/usr/bin/ld: /tmp/cc4iSXYY.o: in function `main':
grader.cpp:(.text.startup+0x696): undefined reference to `solve(int, int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status