Submission #1309429

#TimeUsernameProblemLanguageResultExecution timeMemory
1309429ayuxhkumxr22Cipele (COCI18_cipele)C++20
Compilation error
0 ms0 KiB
bool check(long long x, int n, int m, vector<int>& A, vector<int>& B) { // Ensure A is the smaller array to simplify logic // We must match all elements of the smaller array if (n > m) return check(x, m, n, B, A); int j = 0; // Pointer for larger array B for (int i = 0; i < n; i++) { // Skip elements in B that are too small for A[i] while (j < m && B[j] < A[i] - x) { j++; } // If we ran out of elements in B, we can't match A[i] if (j == m) return false; // If B[j] is too big, it's impossible to match A[i] if (B[j] > A[i] + x) return false; // Match found! Move to next pair j++; } return true; } void solve() { // 1. Input and Sort // 2. Binary Search 0 to 1e9 // 3. Print ans }

Compilation message (stderr)

cipele.cpp:1:39: error: 'vector' has not been declared
    1 | bool check(long long x, int n, int m, vector<int>& A, vector<int>& B) {
      |                                       ^~~~~~
cipele.cpp:1:45: error: expected ',' or '...' before '<' token
    1 | bool check(long long x, int n, int m, vector<int>& A, vector<int>& B) {
      |                                             ^
cipele.cpp: In function 'bool check(long long int, int, int, int)':
cipele.cpp:4:38: error: 'B' was not declared in this scope
    4 |     if (n > m) return check(x, m, n, B, A);
      |                                      ^
cipele.cpp:4:41: error: 'A' was not declared in this scope
    4 |     if (n > m) return check(x, m, n, B, A);
      |                                         ^
cipele.cpp:9:25: error: 'B' was not declared in this scope
    9 |         while (j < m && B[j] < A[i] - x) {
      |                         ^
cipele.cpp:9:32: error: 'A' was not declared in this scope
    9 |         while (j < m && B[j] < A[i] - x) {
      |                                ^
cipele.cpp:16:13: error: 'B' was not declared in this scope
   16 |         if (B[j] > A[i] + x) return false;
      |             ^
cipele.cpp:16:20: error: 'A' was not declared in this scope
   16 |         if (B[j] > A[i] + x) return false;
      |                    ^