Submission #933830

#TimeUsernameProblemLanguageResultExecution timeMemory
933830BzslayedGlobal Warming (NOI13_gw)C++17
40 / 40
179 ms21692 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define ll long long #define pll pair<ll, ll> #define pii pair<int, int> #define pff pair<float, float> #define coutpair(p) cout << p.first << " " << p.second << "\n" typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset; const ll MAXN = 30000005; ll dp[MAXN]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n; cin >> n; int prev = -1; vector<pii> v; int cur = 0; int arr[n]; for (int i=0; i<n; i++){ int a; cin >> a; if (prev == a) continue; v.push_back({a, cur}); prev = a; arr[cur] = a; cur++; } sort(v.begin(), v.end(), greater<pii>()); if (v.size() == 1) { cout << 1; return 0; } int curans = 0; int ans = 0; for (int i = 0; i < cur; i++) { pii c = v[i]; if (c.second == cur-1){ if (arr[c.second-1] <= c.first) curans++; } else if (c.second == 0){ if(arr[c.second+1] < c.first) curans++; } else{ if (arr[c.second-1] > c.first && arr[c.second+1] > c.first) curans--; else if (arr[c.second-1] < c.first && arr[c.second+1] < c.first) curans++; } if (i == cur-1 || v[i].first != v[i+1].first) ans = max(ans, curans); } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...