Link do szkopuła: https://szkopul.edu.pl/problemset/problem/MwIX7XRjTcTpC8twRso8KeF7/site/?key=statement
Napisałem rozwiązanie ale wchodzi tylko na 20:
#include <bits/stdc++.h>
using namespace std;
bool esort(const pair<pair <double, int>, int> &a, const pair<pair <double, int>, int> &b){
if(a == b){
return (a < b);
}
else {
return (a.second < b.second);
}
}
int main() {
int n;
cin >> n;
pair<pair <double, int>, int> T[n];
pair <int, int> waga[n];
for(int i = 0; i < n; i++){
cin >> waga[i].first >> waga[i].second;
T[i].first.first = waga[i].first / pow(2, waga[i].second);
T[i].first.second = i;
T[i].second = waga[i].first;
}
sort(T, T + n, esort);
for(int i = 0; i < n; i++){
cout << waga[T[i].first.second].first << " " << waga[T[i].first.second].second << endl;
}
}