# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
24676 | noobprogrammer | Global Warming (NOI13_gw) | C++14 | 439 ms | 17644 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define ii pair<int,int>
#define vii vector<pair<int,int> >
#define vi vector<int>
int n , par[1000010] , arr[1000010] ;
ii pos[1000010] ;
int find_root(int x){
if(par[x] == x) return x ;
return par[x] = find_root(par[x]) ;
}
int main(){
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
scanf("%d",&n) ;
for(int i=1;i<=n;i++){
scanf("%d",arr+i) ;
pos[i] = {arr[i] , i} ;
par[i] = i ;
}
sort(pos+1 , pos+n+1) ;
int px , py , cur , j , idx , num = 0 , res = 0 ;
for(int i = n ; i> 0 ;){
j = i ; cur = pos[i].fi ;
while(pos[j].fi == cur){
num++ ;
j-- ;
}
while(i>j){
idx = pos[i].se ;
if(arr[idx - 1] >= cur ){
px = find_root(idx) ; py = find_root(idx-1) ;
if(px != py){
num-- ;
par[py] = px ;
}
}
if(arr[idx + 1] >= cur ){
px = find_root(idx) ; py = find_root(idx+1) ;
if(px != py){
num-- ;
par[py] = px ;
}
}
i-- ;
}
res = max( res , num ) ;
}
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... |