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;
#define endl '\n'
#define pb push_back
#define ll long long
#define int ll
const long long inf=1e18;
const int MOD=1e9+7;
const int N=2e5+5;
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n; cin>>n;
pair<int,int> p[n];
for(int i=0;i<n;i++){
cin>>p[i].second>>p[i].first;
p[i].first/=2;
}
sort(p,p+n,greater<pair<int,int>>());
int mx=p[0].second,sum=0;
for(int i=1;i<n;i++){
if(p[i].first!=p[i-1].first)sum+=(p[i-1].first-p[i].first)*mx;
mx=max(mx,p[i].second);
}
sum+=p[n-1].first*mx;
cout<<sum*2;
}
# | 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... |