'commit'
This commit is contained in:
32
TangDou/KaoShi/BABA_5.cpp
Normal file
32
TangDou/KaoShi/BABA_5.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
|
||||
vector<int> count(81, 0);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
int num;
|
||||
cin >> num;
|
||||
count[num]++;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= 80; ++i) {
|
||||
if (count[i] >= 2) {
|
||||
count[i + 1] += count[i] / 2;
|
||||
count[i] %= 2;
|
||||
}
|
||||
}
|
||||
|
||||
int max_num = 0;
|
||||
for (int i = 1; i <= 80; ++i) {
|
||||
if (count[i] > 0) {
|
||||
max_num = i;
|
||||
}
|
||||
}
|
||||
|
||||
cout << max_num << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user