0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 18:52:02 +00:00

P2003 [CRCI2007-2008] PLATFORME 平板

R52416199
This commit is contained in:
Baoshuo Ren 2021-07-05 11:58:43 +08:00 committed by Baoshuo Ren
parent 24d923f814
commit 75d79a2ceb
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

View File

@ -0,0 +1,45 @@
#include <bits/stdc++.h>
using namespace std;
struct node {
int x1, x2, y;
node() {
x1 = x2 = 0;
}
node(int _x1, int _x2, int _y) {
x1 = _x1;
x2 = _x2;
y = _y;
}
const bool operator<(const node& b) {
return y < b.y;
}
} a[1005];
int main() {
int n, ans = 0, h1, h2;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].y >> a[i].x1 >> a[i].x2;
}
for (int i = 1; i <= n; i++) {
h1 = h2 = 0;
for (int j = 1; j <= n; j++) {
if (i == j || a[i].y < a[j].y) {
continue;
}
if (a[i].x1 < a[j].x2 && a[i].x1 >= a[j].x1) {
h1 = max(h1, a[j].y);
}
if (a[i].x2 <= a[j].x2 && a[i].x2 > a[j].x1) {
h2 = max(h2, a[j].y);
}
}
ans += a[i].y * 2 - h1 - h2;
}
cout << ans << endl;
return 0;
}