48542023-04-02 19:40:57Laci3000Völgy (100 pont)cpp11Wrong answer 15/10037ms5340 KiB
#include <iostream>
#include <vector>
using namespace std;

int widestValley(vector<int> measurements) {
    int max_width = -1;
    int valley_start = -1;
    for (int i = 0; i < measurements.size() - 2; i++) {
        // Check if we have a valley starting at i
        if (measurements[i] > measurements[i + 1] && measurements[i + 1] < measurements[i + 2]) {
            valley_start = i;
            // Find the end of the valley
            for (int j = i + 2; j < measurements.size(); j++) {
                if (measurements[j] >= measurements[j - 1]) {
                    int valley_width = j - valley_start - 1;
                    if (valley_width > max_width) {
                        max_width = valley_width;
                    }
                    break;
                }
            }
        }
    }
    return max_width;
}

int main() {
    int n;
    cin >> n;
    vector<int> measurements(n);
    for (int i = 0; i < n; i++) {
        cin >> measurements[i];
    }
    int max_width = widestValley(measurements);
    cout << max_width << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base15/100
1Wrong answer0/03ms1676 KiB
2Wrong answer0/03ms1848 KiB
3Wrong answer0/53ms2064 KiB
4Wrong answer0/52ms2152 KiB
5Wrong answer0/53ms2420 KiB
6Wrong answer0/53ms2352 KiB
7Accepted5/53ms2564 KiB
8Wrong answer0/52ms2688 KiB
9Accepted5/53ms2696 KiB
10Wrong answer0/53ms2832 KiB
11Wrong answer0/54ms3244 KiB
12Wrong answer0/54ms3112 KiB
13Wrong answer0/54ms3120 KiB
14Wrong answer0/56ms3076 KiB
15Wrong answer0/530ms4496 KiB
16Wrong answer0/535ms4576 KiB
17Accepted5/534ms4704 KiB
18Wrong answer0/534ms4916 KiB
19Wrong answer0/535ms5000 KiB
20Wrong answer0/537ms5000 KiB
21Wrong answer0/537ms5128 KiB
22Wrong answer0/537ms5340 KiB