Submission

Status:

[PPPPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: erng

Problemset: จุดตัดบนกราฟ

Language: cpp

Time: 0.047 second

Submitted On: 2026-03-05 23:56:09

#include <bits/stdc++.h>

using namespace std;

#define ll long long

const ll nx=1e5+5;

ll n, cnt, ans, sum;
map<ll,ll> mp;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    ll prev, y;
    cin>>prev;

    for (int i=1; i<n; i++)
    {
        cin>>y;
        ll mn=min(y, prev);
        ll mx=max(prev, y);
        prev=y;
        mp[mn]++;
        mp[mx]--;
    }
    for (auto [idx, cnt] : mp)
    {
        // cout<<idx<<" "<<cnt<<'\n';
        sum+=cnt;
        ans=max(ans, sum);
    }
    cout<<ans;


}
/*
4
1 3 1 3
*/