제출 #1315224

#제출 시각아이디문제언어결과실행 시간메모리
1315224trainingdnns지구 온난화 (NOI13_gw)C++17
40 / 40
375 ms12068 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<int, int>> a(n); for (int i = 0; i < n; ++i) { cin >> a[i].first; a[i].second = i; } sort(a.begin(), a.end(), [](const auto &x, const auto &y) { return x.first > y.first;}); vector<int> seen(n, 0); int curILC = 0; int best = 0; for (int i = 0; i < n; ) { int j = i; while (j < n && a[j].first == a[i].first) { int pos = a[j].second; bool left = (pos > 0 && seen[pos - 1]); bool right = (pos + 1 < n && seen[pos + 1]); if (!left && !right) ++curILC; else if (left && right) --curILC; seen[pos] = 1; ++j; } best = max(best, curILC); i = j; } cout << best << endl; }
#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...