Submission #703227

#TimeUsernameProblemLanguageResultExecution timeMemory
703227delreyUnija (COCI17_unija)C++14
100 / 100
800 ms23464 KiB
#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 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...