Pagini recente » Cod sursa (job #2929524) | Cod sursa (job #1566484) | Cod sursa (job #680088) | Cod sursa (job #2915101) | Cod sursa (job #1588577)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("patrate6.in");
ofstream fout ("patrate6.out");
const int MOD = 73433;
vector < int > G[MOD + 1];
const int BMax = 1e4;
int pos = BMax - 1;
char Buffer[BMax];
unordered_map < int , int > Map;
inline void Read(int &x){
while(!isdigit(Buffer[pos])){
if(++pos == BMax){
fin.read(Buffer, BMax);
pos = 0;
}
}
x = 0;
while(isdigit(Buffer[pos])){
x = x * 10 + (Buffer[pos] - '0');
if(++pos == BMax){
fin.read(Buffer, BMax);
pos = 0;
}
}
}
int main()
{
int n,x,mx;
Read(n);
for(int i = 1; i <= n; i++){
Read(x);
Map[x]++;
while(Map[x] == 4){
Map[x] = 0;
Map[++x]++;
}
if(x > mx)
mx = x;
}
int best = 0;
int ok = 0;
for(auto it: Map){
if(best != it.second && ok == 0) ok = 1;
if(it.second != 0 && it.first > best)
best = it.second;
ok = 1;
}
if(k == 1)
fout << Map.rbegin() -> first;
else
fout << Map.rbegin() -> first + 1;
return 0;
}