CSES - HIIT Open 2024 - Results
Submission details
Task:Forgotten measurements
Sender:Otis++
Submission time:2024-11-16 16:25:56 +0200
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#10.00 sdetails
#20.00 sdetails
#30.00 sdetails
#40.00 sdetails
#50.00 sdetails
#60.00 sdetails
#70.00 sdetails
#80.00 sdetails
#90.00 sdetails
#100.00 sdetails
#110.00 sdetails

Code

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

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

    stack<int> st;
    st.push(0);
    int ans = 0;

    for (int i = 1; i <= n; i++) {

        int x;
        cin >> x;

        while (!st.empty() && st.top() > x) st.pop();

        if (st.empty() || st.top() < x) {
            ans++;
            st.push(x);
        }

    }

    cout << ans;

}

Test details

Test 1

Verdict:

input
ULDRUR

correct output
2

user output
0

Test 2

Verdict:

input
RULD

correct output
2

user output
0

Test 3

Verdict:

input
RULDRURDRURDLULD

correct output
7

user output
0

Test 4

Verdict:

input
LDLDRDLULULURURURULDRDLDRDRURD...

correct output
19

user output
0

Test 5

Verdict:

input
RURULDLULDRURDLULDRULURULURDLD...

correct output
470

user output
0

Test 6

Verdict:

input
DRULDLULDLULDLURDRULDRURDLURDL...

correct output
499773

user output
0

Test 7

Verdict:

input
DLURDLULDLULDRULURULURURDLDLDR...

correct output
499383

user output
0

Test 8

Verdict:

input
RULDLDLDRULDLDLULURULULDLURDLU...

correct output
499622

user output
0

Test 9

Verdict:

input
RDRDRURDLDLURDRULURDLDRULDLULU...

correct output
499788

user output
0

Test 10

Verdict:

input
LDLURDRURDRULDLULDLDRURDLULDRU...

correct output
499368

user output
0

Test 11

Verdict:

input
DRULULDRDLDLDLURULDRDLURULULDR...

correct output
499790

user output
0