코딩테스트/동적계획법
[DP] 백준 14908 구두 수선공 C++
유(YOO)
2022. 1. 27. 12:30
https://www.acmicpc.net/problem/14908
#include<iostream>
#include<vector>
#include<algorithm>
#define INF 1234567891
#define MAX 11
using namespace std;
int n, a, b, ans, sum;
vector<pair<double, double>> arr;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a >> b;
arr.push_back({ (double)b/a, n-(i+1) }); //first내림차순, second오름차순
}
sort(arr.begin(), arr.end(), greater<>());
for (int i = 0; i < n; i++) cout << n-arr[i].second << " ";
}