-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1315.cpp
58 lines (46 loc) · 1.36 KB
/
1315.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Node {
int a,b,c;
};
void solve(){
int N;cin >>N;
Node arr[N]; for (int i = 0; i < N; i++) cin >> arr[i].a >> arr[i].b >> arr[i].c;
int points[1001][1001]; // STR, INT
for (int i = 1; i <= 1000; i++) {
for (int j = 1; j <= 1000; j++) {
points[i][j] = -1;
}
}
bool cleared[1001][1001]; memset(cleared, 0, sizeof(cleared));
cleared[1][0] = cleared[0][1] = points[1][0] = points[0][1] = 1;
int result = 0;
for (int STR = 1; STR <= 1000; STR++) {
for (int INT = 1; INT <= 1000; INT++) {
points[STR][INT] = 2-(STR+INT);
int clear = 0;
for (int i = 0; i < N; i++) {
auto [a,b,c] = arr[i];
if (a <= STR || b <= INT) {
points[STR][INT] += c;
clear++;
}
}
if (
(cleared[STR - 1][INT] && points[STR - 1][INT] > 0) ||
(cleared[STR][INT - 1] && points[STR][INT - 1] > 0)
) {
cleared[STR][INT] = true;
result = max(result, clear);
}
}
}
cout << result;
}
int main()
{
cin.tie(0)->sync_with_stdio(false);
solve();
return 0;
}