39 lines
762 B
C++
39 lines
762 B
C++
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
const int N = 110;
|
|
int t[N], d[N];
|
|
struct Node {
|
|
int id;//第几只兔子
|
|
int t;//跑一趟的消耗时间
|
|
int d;//破坏力
|
|
bool operator<(const Node &b) const {
|
|
return d * 1.0 / t > b.d * 1.0 / b.t;
|
|
}
|
|
} a[N];
|
|
|
|
/*
|
|
6
|
|
3 1
|
|
2 5
|
|
2 3
|
|
3 2
|
|
4 1
|
|
1 6
|
|
*/
|
|
int main() {
|
|
int n;
|
|
cin >> n;
|
|
for (int i = 1; i <= n; i++) cin >> a[i].t >> a[i].d, a[i].id = i;
|
|
sort(a + 1, a + n + 1);
|
|
|
|
// for (int i = 1; i <= n; i++) cout << a[i].id << " ";
|
|
|
|
// 计算破坏了多少花卉
|
|
int sum = 0;
|
|
for (int i = 1; i < n; i++)
|
|
for (int j = i + 1; j <= n; j++)
|
|
sum += a[j].d * a[i].t * 2;
|
|
|
|
cout << sum << endl;
|
|
return 0;
|
|
} |