CSES - Aalto Competitive Programming 2024 - wk5 - Wed - Results
Submission details
Task:Sledding
Sender:aalto2024f_005
Submission time:2024-10-02 16:31:49 +0300
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

cc1plus: error: '::main' must return 'int'

Code

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
#define int long long
using namespace std;

int main()
{
    int n;
    cin >> n;

    vector<int> nums(n);
    for (int i = 0; i < n; i++)
        cin >> nums[i];
    
    int maxDiff = 0;
    int maxS = 0, maxE = 0;

    int start = 0;
    bool inc = nums[0] < nums[1];
    for (int i = 1; i < n; i++)
    {
        if (abs(nums[i] - nums[start]) > maxDiff)
        {
            maxS = start+1;
            maxE = i+1;
            maxDiff = abs(nums[i] - nums[start]);
        }

        bool prev = inc;
        if (i < n-1 && nums[i+1] != nums[i])
            inc = nums[i+1] > nums[i];
        if (prev != inc)
        {
            start = i;
        }
    }

    cout << maxS << " " << maxE << endl;
    
}