Submission
Status:
[PPPPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: sorrkub
Problemset: จุดตัดบนกราฟ
Language: cpp
Time: 0.027 second
Submitted On: 2026-02-11 18:19:14
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; typedef pair<long long ,long long> pll; typedef pair<long long, pair<long long , long long >> plpll;
const int MAX = 1e9+7;
int dx[8] = {0,0,-1,1,-1,1,-1,1} , dy[8] = {1,-1,0,0,1,-1,1,-1};
#define F first
#define S second
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
void solve(){
int n;
cin>>n;
vector<pll> temp;
vector<ll> vec(n);
for(int i=0;i<n;i++){
int a;
cin>>vec[i];
}
for(int i=0;i<n-1;i++){
temp.push_back({min(vec[i],vec[i+1]),1});
temp.push_back({max(vec[i],vec[i+1]),-1});
}
sort(temp.begin(),temp.end());
ll maxx=-1,t=0;
for(auto [f,s] : temp){
t+=s;
maxx = max(maxx,t);
}
cout<<maxx;
}
signed main(){
FAST_IO
int q=1;
//cin>>q;
while(q--){
solve();
}
return 0;
}
/*
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \| |// `.
/ \||| : |||// \
/ _||||| -:- |||||- \
| | \ - /// | |
| \_| ''\---/'' | |
\ .-\__ `-` ___/-. /
___`. .' /--.--\ `. . __
."" '< `.___\_<|>_/___.' >'"".
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `-. \_ __\ /__ _/ .-` / /
======`-.____`-.___\_____/___.-`____.-'======
`=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pass System Test!
*/