This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n;
vector < pair<int, int> > v;
int main()
{
cin>>n;
for(int i = 0; i < n; i++)
{
int x, y;
cin>>x>>y;
v.push_back({x, y});
}
sort(v.begin(), v.end());
long long res = 0;
int tallest = -1;
for(int i = n - 1; i > 0; i--)
{
tallest = max(tallest, v[i].second);
res += (v[i].first - v[i - 1].first) * tallest;
//cout<<"tallest: "<<tallest<<" v["<<i<<"].first: "<<v[i].first<<" v["<<i - 1<<"].first: "<<v[i - 1].first<<endl;
}
tallest = max(tallest, v[0].second);
res += v[0].first * tallest;
cout<<res<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |