# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
703227 |
2023-02-26T15:57:58 Z |
delrey |
Unija (COCI17_unija) |
C++14 |
|
800 ms |
23464 KB |
#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 |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
340 KB |
Output is correct |
2 |
Correct |
4 ms |
448 KB |
Output is correct |
3 |
Correct |
4 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
700 ms |
23344 KB |
Output is correct |
2 |
Correct |
800 ms |
23228 KB |
Output is correct |
3 |
Correct |
727 ms |
23292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
992 KB |
Output is correct |
2 |
Correct |
19 ms |
952 KB |
Output is correct |
3 |
Correct |
22 ms |
1008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
65 ms |
2496 KB |
Output is correct |
2 |
Correct |
65 ms |
2480 KB |
Output is correct |
3 |
Correct |
67 ms |
2508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
263 ms |
8140 KB |
Output is correct |
2 |
Correct |
192 ms |
8128 KB |
Output is correct |
3 |
Correct |
191 ms |
8236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
733 ms |
23464 KB |
Output is correct |
2 |
Correct |
716 ms |
23456 KB |
Output is correct |
3 |
Correct |
681 ms |
23212 KB |
Output is correct |