Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <cmath>
- #include <iostream>
- #include <list>
- #include <set>
- #include <utility>
- #include <vector>
- using namespace std;
- struct ak {
- long long k;
- long long a;
- };
- int main() {
- int n;
- cin >> n;
- vector<ak> data(n);
- for(int i = 0; i < n; i++) {
- cin >> data[i].k;
- cin >> data[i].a;
- }
- //From max to min
- sort(data.begin(), data.end(), [](const ak &a, const ak &b){return a.k > b.k;});
- long long r = data[0].k + 1;
- bool allok = false;
- while(!allok) {
- allok = true;
- for(int i = 0; i < n; i++) {
- ak cur = data[i];
- double new_r = log(cur.a)/log(4);
- if( (r-cur.k) < new_r ) {
- allok = false;
- r = (new_r > (r+1) ? new_r : r+1);
- break;
- }
- }
- }
- cout << r;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement