Created
May 17, 2016 01:32
-
-
Save joaogui1/4fb01c7a7a72ced06aff5678c79ae4ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
#define MAXN 1000100 | |
set<int> s; | |
int altura[MAXN],cont[MAXN]; | |
int n,ans; | |
int main(){ | |
scanf("%d", &n); | |
for(int i = 0; i < n; i++){ | |
scanf("%d", &altura[i]); | |
cont[altura[i]]++; | |
s.insert(altura[i]); | |
} | |
set<int>::iterator it; | |
for(int i = 0; i < n; i++){ | |
if(cont[altura[i]] != 0){ | |
int x = altura[i]; | |
ans++; | |
cont[x]--; | |
while(true){ | |
x--; | |
it = s.find(x); | |
if(it != s.end() && cont[x] > 0) | |
cont[x]--; | |
else break; | |
} | |
} | |
} | |
printf("%d\n",ans); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment