Submission

Status:

[PPPPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: 12345678

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

Language: cpp

Time: 0.044 second

Submitted On: 2025-11-27 21:12:05

#include <bits/stdc++.h>

using namespace std;

const int nx=1e5+5;

int n, p[nx], sm, mx;
map<int, int> mp;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++) cin>>p[i];
    for (int i=2; i<=n; i++)
    {
        int l=p[i-1], r=p[i];
        if (r<l) swap(l, r);
        mp[l]++;
        mp[r]--;
    }    
    for (auto [x, y]:mp)
    {
        sm+=y;
        // cout<<"debug "<<x<<' '<<sm<<'\n';
        mx=max(mx, sm);
    }
    cout<<mx;
}