답안 #1023158

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1023158 2024-07-14T11:21:31 Z avighna 지구 온난화 (NOI13_gw) C++17
30 / 40
181 ms 33364 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;
  vector<ll> h(n);
  vector<pair<ll, ll>> hsort(n);
  vector<bool> present(n, true);
  for (ll i = 0; i < n; ++i) {
    cin >> h[i];
    hsort[i].first = h[i];
    hsort[i].second = i;
  }
  sort(hsort.begin(), hsort.end());

  if (n == 1) {
    cout << "1\n";
    return 0;
  }

  ll ans = 1, isl = 1;
  for (ll i = 0; i < n; ++i) {
    if (i != 0 && hsort[i].first != hsort[i - 1].first) {
      ans = max(ans, isl);
    }
    ll idx = hsort[i].second;
    present[idx] = false;
    if (idx == 0) {
      isl -= !present[1];
      continue;
    }
    if (idx == n - 1) {
      isl -= !present[n - 2];
      continue;
    }
    if (!present[idx - 1] && !present[idx + 1]) {
      isl--;
      continue;
    }
    if (present[idx - 1] && present[idx + 1]) {
      isl++;
      continue;
    }
  }
  ans = max(ans, isl);
  cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 3088 KB Output is correct
2 Correct 14 ms 2908 KB Output is correct
3 Correct 17 ms 3160 KB Output is correct
4 Correct 14 ms 3084 KB Output is correct
5 Correct 14 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 3668 KB Output is correct
2 Correct 9 ms 3460 KB Output is correct
3 Correct 14 ms 3668 KB Output is correct
4 Correct 15 ms 3420 KB Output is correct
5 Correct 14 ms 3420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 168 ms 33364 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 170 ms 32596 KB Output is correct
2 Correct 181 ms 32504 KB Output is correct
3 Correct 172 ms 32596 KB Output is correct
4 Correct 146 ms 26864 KB Output is correct
5 Correct 146 ms 26704 KB Output is correct