| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 981613 | ShauryaTheShep | Gap (APIO16_gap) | C++14 | 0 ms | 0 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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, ¤t_min, ¤t_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;
}
