| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 24676 | noobprogrammer | Global Warming (NOI13_gw) | C++14 | 439 ms | 17644 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
Compilation message (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... | ||||
