Submission #926831

# Submission time Handle Problem Language Result Execution time Memory
926831 2024-02-13T21:06:24 Z OAleksa Team Contest (JOI22_team) C++14
0 / 100
254 ms 510952 KB
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
const int N = 15069;
const int A = 4010;
const int inf = 1e9;
int n, a[N], b[N], c[N], d[A][A];
int gmx[A][A], gmn[A][A], mn[A][A];

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
  	cin >> n;
  	for (int i = 1;i <= n;i++)
  		cin >> a[i] >> b[i] >> c[i];
  	for (int i = 0;i < A;i++) {
  		for (int j = 0;j < A;j++) {
  			gmn[i][j] = inf;
  			gmx[i][j] = -inf;
  			d[i][j] = -inf;
  			mn[i][j] = inf;
  		}
  	}
  	for (int i = 1;i <= n;i++) {
  		gmx[a[i]][b[i]] = max(c[i], gmx[a[i]][b[i]]);
  		gmn[a[i]][b[i]] = min(c[i], gmn[a[i]][b[i]]);
  	}
  	for (int i = 1;i < A;i++) {
  		for (int j = 1;j < A;j++) {
  			d[i][j] = max({d[i][j - 1], d[i - 1][j], gmx[i][j]});
  			mn[i][j] = min(mn[i][j - 1], gmn[i][j]);
  		}
  	}
  	int ans = -1;
  	for (int i = 1;i <= n;i++) {
  		for (int j = a[i] + 1;j < A;j++) {
  			if (mn[j][b[i] - 1] < d[j - 1][b[i] - 1] && d[j - 1][b[i] - 1] > c[i]) {
  				ans = max(ans, b[i] + j + d[j - 1][b[i] - 1]);
  			}
  		}
  	}
  	cout << ans << '\n';
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 111 ms 252188 KB Output is correct
2 Correct 110 ms 252180 KB Output is correct
3 Correct 112 ms 252184 KB Output is correct
4 Correct 114 ms 252188 KB Output is correct
5 Correct 112 ms 251984 KB Output is correct
6 Correct 111 ms 251988 KB Output is correct
7 Correct 112 ms 251984 KB Output is correct
8 Correct 112 ms 252180 KB Output is correct
9 Correct 110 ms 252184 KB Output is correct
10 Correct 110 ms 252188 KB Output is correct
11 Correct 111 ms 252012 KB Output is correct
12 Correct 111 ms 252000 KB Output is correct
13 Correct 109 ms 251984 KB Output is correct
14 Runtime error 254 ms 510952 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 111 ms 252188 KB Output is correct
2 Correct 110 ms 252180 KB Output is correct
3 Correct 112 ms 252184 KB Output is correct
4 Correct 114 ms 252188 KB Output is correct
5 Correct 112 ms 251984 KB Output is correct
6 Correct 111 ms 251988 KB Output is correct
7 Correct 112 ms 251984 KB Output is correct
8 Correct 112 ms 252180 KB Output is correct
9 Correct 110 ms 252184 KB Output is correct
10 Correct 110 ms 252188 KB Output is correct
11 Correct 111 ms 252012 KB Output is correct
12 Correct 111 ms 252000 KB Output is correct
13 Correct 109 ms 251984 KB Output is correct
14 Runtime error 254 ms 510952 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 110 ms 251984 KB Output is correct
2 Correct 110 ms 251980 KB Output is correct
3 Correct 110 ms 252004 KB Output is correct
4 Correct 110 ms 252008 KB Output is correct
5 Correct 111 ms 252244 KB Output is correct
6 Correct 109 ms 252188 KB Output is correct
7 Correct 109 ms 252184 KB Output is correct
8 Correct 110 ms 251960 KB Output is correct
9 Correct 111 ms 251988 KB Output is correct
10 Correct 110 ms 251984 KB Output is correct
11 Incorrect 112 ms 252244 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 110 ms 251984 KB Output is correct
2 Correct 110 ms 251980 KB Output is correct
3 Correct 110 ms 252004 KB Output is correct
4 Correct 110 ms 252008 KB Output is correct
5 Correct 111 ms 252244 KB Output is correct
6 Correct 109 ms 252188 KB Output is correct
7 Correct 109 ms 252184 KB Output is correct
8 Correct 110 ms 251960 KB Output is correct
9 Correct 111 ms 251988 KB Output is correct
10 Correct 110 ms 251984 KB Output is correct
11 Incorrect 112 ms 252244 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 110 ms 251984 KB Output is correct
2 Correct 110 ms 251980 KB Output is correct
3 Correct 110 ms 252004 KB Output is correct
4 Correct 110 ms 252008 KB Output is correct
5 Correct 111 ms 252244 KB Output is correct
6 Correct 109 ms 252188 KB Output is correct
7 Correct 109 ms 252184 KB Output is correct
8 Correct 110 ms 251960 KB Output is correct
9 Correct 111 ms 251988 KB Output is correct
10 Correct 110 ms 251984 KB Output is correct
11 Incorrect 112 ms 252244 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 110 ms 251984 KB Output is correct
2 Correct 110 ms 251980 KB Output is correct
3 Correct 110 ms 252004 KB Output is correct
4 Correct 110 ms 252008 KB Output is correct
5 Correct 111 ms 252244 KB Output is correct
6 Correct 109 ms 252188 KB Output is correct
7 Correct 109 ms 252184 KB Output is correct
8 Correct 110 ms 251960 KB Output is correct
9 Correct 111 ms 251988 KB Output is correct
10 Correct 110 ms 251984 KB Output is correct
11 Incorrect 112 ms 252244 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 111 ms 252188 KB Output is correct
2 Correct 110 ms 252180 KB Output is correct
3 Correct 112 ms 252184 KB Output is correct
4 Correct 114 ms 252188 KB Output is correct
5 Correct 112 ms 251984 KB Output is correct
6 Correct 111 ms 251988 KB Output is correct
7 Correct 112 ms 251984 KB Output is correct
8 Correct 112 ms 252180 KB Output is correct
9 Correct 110 ms 252184 KB Output is correct
10 Correct 110 ms 252188 KB Output is correct
11 Correct 111 ms 252012 KB Output is correct
12 Correct 111 ms 252000 KB Output is correct
13 Correct 109 ms 251984 KB Output is correct
14 Runtime error 254 ms 510952 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -