Submission #981614

# Submission time Handle Problem Language Result Execution time Memory
981614 2024-05-13T11:39:24 Z ShauryaTheShep Gap (APIO16_gap) C++17
Compilation error
0 ms 0 KB
#include <iostream>
using namespace std;

// Assuming MinMax is correctly implemented and linked
extern void MinMax(long long s, long long t, long long* mn, long long* mx);

long long findGap(int T, int N) {
    if (T == 1) {
        long long min_value, max_value;
        // Get the overall minimum and maximum to start
        MinMax(0, 1LL << 60, &min_value, &max_value); // using large number assuming range

        if (min_value == -1) // No values found within the range
            return 0;

        // Variables to store the results of MinMax calls
        long long prev_value = min_value;
        long long max_gap = 0;
        long long current_min, current_max;

        // Checking each segment, starting from min_value to max_value
        long long current_position = min_value;
        while (current_position <= max_value) {
            MinMax(current_position, max_value, &current_min, &current_max);
            if (current_min == -1) break; // No more numbers in this segment

            // Calculate the gap
            if (current_min - prev_value > max_gap) {
                max_gap = current_min - prev_value;
            }
            prev_value = current_max;
            current_position = current_max + 1; // Move to the next segment
        }

        return max_gap;
    }
    return -1; // For subtask 2, to be implemented later
}

int main() {
    int T = 1; // Subtask number
    int N;    // Number of elements, must be set appropriately

    cout << "Enter the number of elements N: ";
    cin >> N;

    cout << "The maximum gap is: " << findGap(T, N) << endl;
    return 0;
}

Compilation message

/usr/bin/ld: /tmp/ccdX2e5A.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccVhkXKx.o:gap.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status