Submission

Status:
[PPPPPPPPPPPPPPP]

Score: 100

User: Dormon

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

Language: cpp

Time: 0.055 second

Submitted On: 2025-03-27 11:46:51

#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    map<int, int> mp;
    int n, pre;
    cin >> n >> pre;

    for (int i = 1;i < n;i++){
        int now;
        cin >> now;
        mp[max(pre, now)]--;
        mp[min(pre, now)]++;
        pre = now;
    }

    int cnt = 0, ans = 0;
    for (auto [now, p]:mp){
        cnt += p;
        ans = max(ans, cnt);
    }
    cout << ans << '\n';
}