Submission
Status:
[PPPPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: letdown
Problemset: จุดตัดบนกราฟ
Language: cpp
Time: 0.045 second
Submitted On: 2026-03-12 11:27:06
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
cin.tie(NULL)->sync_with_stdio(0);
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
map<int, int> mp;
for (int i = 0; i < n-1; i++) {
int p1 = a[i]*2, p2 = a[i+1]*2;
if (p1 < p2) {
mp[p1]++;
mp[p2]--;
} else {
mp[p1]--;
mp[p2]++;
}
}
int mx = 0, cur = 0;
for (auto i : mp) {
cur += i.second;
mx = max(mx, cur);
}
cout << mx;
}