Submission #847859

#TimeUsernameProblemLanguageResultExecution timeMemory
847859vjudge1Unija (COCI17_unija)C++17
100 / 100
254 ms31308 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...