Submission

Status:

[PPPPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: tha_smith

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

Language: cpp

Time: 0.047 second

Submitted On: 2026-03-07 14:23:21

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

int main() {
	ios_base::sync_with_stdio(0),cin.tie(0);
	ll N,prev; map<ll,ll> m;
	cin >> N >> prev;
	for(int i=1; i<N; i++) {
		ll y;
		cin >> y;
		ll mn = min(prev,y);
		ll mx = max(prev,y);
		m[mn]++;
		m[mx]--;
		prev = y;
	}
	ll ans=0,sum=0;
	for(auto[idx,count]:m) {
		sum+=count;
		ans=max(ans,sum);
	}
	cout << ans;
}