# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
25140 | zoomswk | 지구 온난화 (NOI13_gw) | C++14 | 413 ms | 12836 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
pair<int, int> h[1000005];
int par[1000005];
int findpar(int x){
if(par[x] != x) par[x] = findpar(par[x]);
return par[x];
}
int main(){
int n;
scanf("%d", &n);
for(int i=0; i<n; i++){
scanf("%d", &h[i].first);
h[i].second = i;
}
sort(h, h+n);
int res = 0, cur = 0;
for(int i=0; i<=n; i++) par[i] = n;
for(int i=n-1; i>=0; i--){
cur++;
par[h[i].second] = h[i].second;
if(i == 0 || h[i].first != h[i-1].first){
int ptr = i;
while(ptr < n && h[ptr].first == h[i].first){
int pos = h[ptr].second;
int u = findpar(pos);
if(pos != n-1){
int v = findpar(pos+1);
if(v != n && u != v) par[v] = u, cur--;
}
if(pos != 0){
int v = findpar(pos-1);
if(v != n && u != v) par[v] = u, cur--;
}
ptr++;
}
if(cur > res) res = cur;
}
}
printf("%d", res);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |