Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int F, M, N;
- struct Items{
- int f;
- int m;
- int id;
- Items(){};
- Items(int f1, int m1, int id1){
- f = f1;
- m = m1;
- id = id1;
- };
- };
- bool comp(Items a, Items b){
- return a.f*b.m > a.m * b.f;
- }
- int main(){
- ios_base::sync_with_stdio(0), cin.tie(0);
- // freopen("rcupgrade.in", "r", stdin);
- cin >> F >> M >> N;
- int a, b;
- Items item[N];
- for(int i=0; i<N; i++){
- cin >> a >> b;
- item[i].f = a;
- item[i].m = b;
- item[i].id = i+1;
- }
- sort(item, item+N, comp);
- int res[N];
- int count = 0;
- for(int i=0; i<N; i++){
- int f = item[i].f;
- int m = item[i].m;
- if(F*m < M*f){
- res[count] = item[i].id;
- // cout << "i: " << i << ", item: " << item[i].id << ", force: " << item[i].f << ", mass: " << item[i].m << '\n';
- count++;
- F+=f;
- M+=m;
- }
- }
- if(count == 0){
- cout << "NONE" << '\n';
- }else{
- sort(res, res+count);
- for(int i=0; i<count; i++){
- cout << res[i] << '\n';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement