CSES - Datatähti 2021 alku - Results
Submission details
Task:Alitaulukot
Sender:Salama
Submission time:2020-10-01 17:49:37 +0300
Language:C++17
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:30:9: error: expected ';' before '}' token
         }
         ^

Code

#include <iostream>
#include <string>
using namespace std;

int main() {
    int listSize, biggestSub;
    cin >> listSize >> biggestSub;
    int list[100000];
    int ans = 0;
    
    for (int i = 0; i < listSize; i++) {
        cin >> list[i];
    }
    int index = 0;
    int i, smallestInList, biggestInList;

    while (index < listSize) {
        i = 0;
        smallestInList = 1000000001;
        biggestInList = -1;
        while (true) {
            if (index + i == listSize) break;
            else if (list[index + i] < smallestInList)
                smallestInList = list[index + i];
            else if (list[index + i] > biggestInList)
                biggestInList = list[index + i];
            if(biggestInList - smallestInList > biggestSub) break;
            i++;
            ans++
        }
        index++;
        //ans += i;
    }
    cout << ans;
}