Submission #926829

# Submission time Handle Problem Language Result Execution time Memory
926829 2024-02-13T21:02:57 Z OAleksa Team Contest (JOI22_team) C++14
0 / 100
2000 ms 1028424 KB
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define int long long
const int N = 2e5 + 69;
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 222 ms 507464 KB Output is correct
2 Correct 137 ms 507216 KB Output is correct
3 Correct 137 ms 507220 KB Output is correct
4 Correct 137 ms 507308 KB Output is correct
5 Correct 137 ms 507216 KB Output is correct
6 Correct 135 ms 507392 KB Output is correct
7 Correct 136 ms 507452 KB Output is correct
8 Correct 147 ms 507376 KB Output is correct
9 Correct 136 ms 507220 KB Output is correct
10 Correct 142 ms 507220 KB Output is correct
11 Correct 138 ms 507268 KB Output is correct
12 Correct 137 ms 507396 KB Output is correct
13 Correct 135 ms 507352 KB Output is correct
14 Runtime error 550 ms 1028424 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 222 ms 507464 KB Output is correct
2 Correct 137 ms 507216 KB Output is correct
3 Correct 137 ms 507220 KB Output is correct
4 Correct 137 ms 507308 KB Output is correct
5 Correct 137 ms 507216 KB Output is correct
6 Correct 135 ms 507392 KB Output is correct
7 Correct 136 ms 507452 KB Output is correct
8 Correct 147 ms 507376 KB Output is correct
9 Correct 136 ms 507220 KB Output is correct
10 Correct 142 ms 507220 KB Output is correct
11 Correct 138 ms 507268 KB Output is correct
12 Correct 137 ms 507396 KB Output is correct
13 Correct 135 ms 507352 KB Output is correct
14 Runtime error 550 ms 1028424 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 143 ms 507440 KB Output is correct
2 Correct 139 ms 507216 KB Output is correct
3 Correct 136 ms 507216 KB Output is correct
4 Correct 140 ms 507452 KB Output is correct
5 Correct 137 ms 507332 KB Output is correct
6 Correct 135 ms 507332 KB Output is correct
7 Correct 138 ms 507728 KB Output is correct
8 Correct 139 ms 507220 KB Output is correct
9 Correct 137 ms 507216 KB Output is correct
10 Correct 135 ms 507216 KB Output is correct
11 Execution timed out 2051 ms 508256 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 143 ms 507440 KB Output is correct
2 Correct 139 ms 507216 KB Output is correct
3 Correct 136 ms 507216 KB Output is correct
4 Correct 140 ms 507452 KB Output is correct
5 Correct 137 ms 507332 KB Output is correct
6 Correct 135 ms 507332 KB Output is correct
7 Correct 138 ms 507728 KB Output is correct
8 Correct 139 ms 507220 KB Output is correct
9 Correct 137 ms 507216 KB Output is correct
10 Correct 135 ms 507216 KB Output is correct
11 Execution timed out 2051 ms 508256 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 143 ms 507440 KB Output is correct
2 Correct 139 ms 507216 KB Output is correct
3 Correct 136 ms 507216 KB Output is correct
4 Correct 140 ms 507452 KB Output is correct
5 Correct 137 ms 507332 KB Output is correct
6 Correct 135 ms 507332 KB Output is correct
7 Correct 138 ms 507728 KB Output is correct
8 Correct 139 ms 507220 KB Output is correct
9 Correct 137 ms 507216 KB Output is correct
10 Correct 135 ms 507216 KB Output is correct
11 Execution timed out 2051 ms 508256 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 143 ms 507440 KB Output is correct
2 Correct 139 ms 507216 KB Output is correct
3 Correct 136 ms 507216 KB Output is correct
4 Correct 140 ms 507452 KB Output is correct
5 Correct 137 ms 507332 KB Output is correct
6 Correct 135 ms 507332 KB Output is correct
7 Correct 138 ms 507728 KB Output is correct
8 Correct 139 ms 507220 KB Output is correct
9 Correct 137 ms 507216 KB Output is correct
10 Correct 135 ms 507216 KB Output is correct
11 Execution timed out 2051 ms 508256 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 222 ms 507464 KB Output is correct
2 Correct 137 ms 507216 KB Output is correct
3 Correct 137 ms 507220 KB Output is correct
4 Correct 137 ms 507308 KB Output is correct
5 Correct 137 ms 507216 KB Output is correct
6 Correct 135 ms 507392 KB Output is correct
7 Correct 136 ms 507452 KB Output is correct
8 Correct 147 ms 507376 KB Output is correct
9 Correct 136 ms 507220 KB Output is correct
10 Correct 142 ms 507220 KB Output is correct
11 Correct 138 ms 507268 KB Output is correct
12 Correct 137 ms 507396 KB Output is correct
13 Correct 135 ms 507352 KB Output is correct
14 Runtime error 550 ms 1028424 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -