#include <iostream>
#include <bitset>
#include <vector>
using namespace std;
// constexpr static const size_t X = 16;
constexpr static const size_t X = 201718 + 200;
void update(bitset<X>& b, size_t i) {
while (b[i])
b[i++] = false;
b[i] = true;
}
int main() {
ios::sync_with_stdio(false);
int n;
cin >> n;
bitset<X> x;
for (int i = 0; i < n; ++i) {
int y;
cin >> y;
update(x, y);
}
int b = 0;
for (int i = X - 1; i >= 0; --i) {
if (x[i]) {
b = i;
break;
}
}
cout << b << '\n';
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #include <iostream> #include <bitset> #include <vector> using namespace std; // constexpr static const size_t X = 16; constexpr static const size_t X = 201718 + 200; void update(bitset<X>& b, size_t i) { while (b[i]) b[i++] = false; b[i] = true; } int main() { ios::sync_with_stdio(false); int n; cin >> n; bitset<X> x; for (int i = 0; i < n; ++i) { int y; cin >> y; update(x, y); } int b = 0; for (int i = X - 1; i >= 0; --i) { if (x[i]) { b = i; break; } } cout << b << '\n'; return 0; } |
English