#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool sorting(pair<ll, ll> a, pair<ll, ll> b) {
if (a.first == b.first) {
return a.second > b.second;
}
return a.first < b.first;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
ll n;
cin >> n;
vector<pair<ll, ll>> v(n + 1);
for (int i = 0; i < n; i++) {
cin >> v[i].first >> v[i].second;
}
v[n] = { 0, 100000000 };
sort(v.begin(), v.end(), sorting);
ll rez = 0;
// ll prevHeight = v[0].second;
for (int i = 1; i <= n; i++) {
if (i != n && v[i].second == v[i + 1].second) {
continue;
}
rez += (v[i].first - v[i - 1].first) * v[i].second;
}
cout << rez << endl;
// int n;
// cin >> n;
// vector<pair<int,int>> pravoagolnik(n);
// for (int i=0;i<n;i++) {
// cin >> pravoagolnik[i].first >> pravoagolnik[i].second;
// pravoagolnik[i].first/=2;
// pravoagolnik[i].second/=2;
// }
// sort(pravoagolnik.begin(), pravoagolnik.end());
// int rez = pravoagolnik[0].first * pravoagolnik[0].second;
// for (int i=1;i<n;i++) {
// rez += (pravoagolnik[i].first-pravoagolnik[i-1].first) * pravoagolnik[i].second;
// }
// cout << 4 * rez << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
241 ms |
15960 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
856 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
1884 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
73 ms |
4956 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
212 ms |
15964 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |