/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 532.0 KiB
#2 Wrong Answer 1ms 324.0 KiB

Code

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> heights(n);
    
    for (int i = 0; i < n; ++i) {
        cin >> heights[i];
    }

    for (int i = 0; i < n; ++i) {
        for (int j = i; j < n && (j - i + 1) <= k; ++j) {
            vector<int> segment(heights.begin() + i, heights.begin() + j + 1);
            sort(segment.begin(), segment.end());

            bool valid = true;
            for (int m = 1; m < segment.size(); ++m) {
                if (segment[m] < segment[m - 1]) {
                    valid = false;
                    break;
                }
            }

            if (valid) {
                cout << "YES\n" << i + 1 << " " << j + 1 << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1120 Stairway to the Skyline
Contest
Brain Booster #7
Language
C++11 (G++ 13.2.0)
Submit At
2024-11-05 15:07:35
Judged At
2024-11-11 02:31:29
Judged By
Score
0
Total Time
1ms
Peak Memory
532.0 KiB