# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
516317 | 2022-01-21T05:20:15 Z | Jomnoi | 지구 온난화 (NOI13_gw) | C++17 | 270 ms | 22524 KB |
#include <bits/stdc++.h> #define DEBUG 0 using namespace std; const int N = 1e6 + 10; int parent[N]; bool appeared[N]; int root(int u) { if(u == parent[u]) { return u; } return parent[u] = root(parent[u]); } int main() { int n; scanf(" %d", &n); for(int i = 1; i <= n; i++) { parent[i] = i; } vector <pair <int, int>> vec; for(int i = 1; i <= n; i++) { int h; scanf(" %d", &h); vec.emplace_back(h, i); } sort(vec.rbegin(), vec.rend()); int cmp = 0, ans = 0; for(auto [h, i] : vec) { cmp++; appeared[i] = true; if(appeared[i - 1] == true) { cmp--; parent[root(i)] = root(i - 1); } if(appeared[i + 1] == true) { cmp--; parent[root(i)] = root(i + 1); } ans = max(ans, cmp); } printf("%d", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 20 ms | 2092 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 2600 KB | Output is correct |
2 | Correct | 18 ms | 2500 KB | Output is correct |
3 | Correct | 24 ms | 2572 KB | Output is correct |
4 | Correct | 25 ms | 2500 KB | Output is correct |
5 | Correct | 23 ms | 2600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 268 ms | 22524 KB | Output is correct |
2 | Correct | 254 ms | 22432 KB | Output is correct |
3 | Correct | 264 ms | 22436 KB | Output is correct |
4 | Correct | 263 ms | 22416 KB | Output is correct |
5 | Correct | 252 ms | 21812 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 270 ms | 21788 KB | Output is correct |
2 | Correct | 250 ms | 21756 KB | Output is correct |
3 | Correct | 261 ms | 21824 KB | Output is correct |
4 | Incorrect | 217 ms | 15900 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |