Editorial for 社內賽
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
僅供參考
#define pb push_back
#define ll long long
#define pll pair<long long, long long>
#define all(x) x.begin(), x.end()
using namespace std;
const ll p = 1e9+7;
int main() {
ll n;cin >> n;
vector<pll> v;
for(int i = 0;i < n;i++) {
ll a, b;cin >> a >> b;
v.pb({a, b});
}
sort(all(v), [](pll a, pll b) {
return a.second*b.first < a.first*b.second;
});
ll now = 0, ans = 0;
for(auto i : v) {
now += i.second;
now %= p;
ans += now*i.first;
ans %= p;
}
cout << ans;
return 0;
}
Comments