Submission

Status:

[PPPPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: C12

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

Language: cpp

Time: 0.165 second

Submitted On: 2026-01-03 23:51:46

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

#define f first
#define s second
#define pii pair<ll,ll>
#define puii pair<ull,ull>
#define piii pair<ll,pii>
#define ll long long
#define ull unsigned long long
#define mp make_pair
 
#define mpiii(a,b,c) make_pair(a,make_pair(b,c));
// ll mod = 1000000007;

void solve(){
    int n;

    cin >> n;

    map<ll,ll>m;
    map<ll,ll>point;

    ll old,neww;

    cin >> old;
    point[old]++;

    for(int i = 1;i < n;i++){
        cin >> neww;
        if(old < neww){
            m[old]++;
            m[neww]--;
        }
        else{
            m[old]--;
            m[neww]++;
        }
        old = neww;
        point[old]++;
    }
    ll last = old;

    ll mx = LLONG_MIN;
    ll cnt = 0;
    for(auto x:m){
        cnt += x.second;
        mx = max(mx,cnt);
    }

    for(auto x:point){
        mx = max(mx,x.second);
    }

    cout << mx;

    return;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    ll q;
 
    // cin >> q;

    // while(q--)
        solve(); 

    return 0;
}