Submission #926832

# Submission time Handle Problem Language Result Execution time Memory
926832 2024-02-13T21:08:17 Z OAleksa Team Contest (JOI22_team) C++14
0 / 100
2000 ms 512712 KB
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
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 109 ms 252976 KB Output is correct
2 Correct 111 ms 252836 KB Output is correct
3 Correct 110 ms 253016 KB Output is correct
4 Correct 110 ms 252940 KB Output is correct
5 Correct 113 ms 253012 KB Output is correct
6 Correct 110 ms 253092 KB Output is correct
7 Correct 111 ms 253012 KB Output is correct
8 Correct 111 ms 253016 KB Output is correct
9 Correct 110 ms 253012 KB Output is correct
10 Correct 114 ms 252804 KB Output is correct
11 Correct 109 ms 253008 KB Output is correct
12 Correct 112 ms 253008 KB Output is correct
13 Correct 109 ms 253016 KB Output is correct
14 Runtime error 248 ms 512712 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 109 ms 252976 KB Output is correct
2 Correct 111 ms 252836 KB Output is correct
3 Correct 110 ms 253016 KB Output is correct
4 Correct 110 ms 252940 KB Output is correct
5 Correct 113 ms 253012 KB Output is correct
6 Correct 110 ms 253092 KB Output is correct
7 Correct 111 ms 253012 KB Output is correct
8 Correct 111 ms 253016 KB Output is correct
9 Correct 110 ms 253012 KB Output is correct
10 Correct 114 ms 252804 KB Output is correct
11 Correct 109 ms 253008 KB Output is correct
12 Correct 112 ms 253008 KB Output is correct
13 Correct 109 ms 253016 KB Output is correct
14 Runtime error 248 ms 512712 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 110 ms 253004 KB Output is correct
2 Correct 111 ms 253012 KB Output is correct
3 Correct 110 ms 253012 KB Output is correct
4 Correct 110 ms 252880 KB Output is correct
5 Correct 116 ms 253016 KB Output is correct
6 Correct 109 ms 253020 KB Output is correct
7 Correct 109 ms 253008 KB Output is correct
8 Correct 109 ms 253016 KB Output is correct
9 Correct 109 ms 253012 KB Output is correct
10 Correct 109 ms 253012 KB Output is correct
11 Execution timed out 2037 ms 254032 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 110 ms 253004 KB Output is correct
2 Correct 111 ms 253012 KB Output is correct
3 Correct 110 ms 253012 KB Output is correct
4 Correct 110 ms 252880 KB Output is correct
5 Correct 116 ms 253016 KB Output is correct
6 Correct 109 ms 253020 KB Output is correct
7 Correct 109 ms 253008 KB Output is correct
8 Correct 109 ms 253016 KB Output is correct
9 Correct 109 ms 253012 KB Output is correct
10 Correct 109 ms 253012 KB Output is correct
11 Execution timed out 2037 ms 254032 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 110 ms 253004 KB Output is correct
2 Correct 111 ms 253012 KB Output is correct
3 Correct 110 ms 253012 KB Output is correct
4 Correct 110 ms 252880 KB Output is correct
5 Correct 116 ms 253016 KB Output is correct
6 Correct 109 ms 253020 KB Output is correct
7 Correct 109 ms 253008 KB Output is correct
8 Correct 109 ms 253016 KB Output is correct
9 Correct 109 ms 253012 KB Output is correct
10 Correct 109 ms 253012 KB Output is correct
11 Execution timed out 2037 ms 254032 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 110 ms 253004 KB Output is correct
2 Correct 111 ms 253012 KB Output is correct
3 Correct 110 ms 253012 KB Output is correct
4 Correct 110 ms 252880 KB Output is correct
5 Correct 116 ms 253016 KB Output is correct
6 Correct 109 ms 253020 KB Output is correct
7 Correct 109 ms 253008 KB Output is correct
8 Correct 109 ms 253016 KB Output is correct
9 Correct 109 ms 253012 KB Output is correct
10 Correct 109 ms 253012 KB Output is correct
11 Execution timed out 2037 ms 254032 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 109 ms 252976 KB Output is correct
2 Correct 111 ms 252836 KB Output is correct
3 Correct 110 ms 253016 KB Output is correct
4 Correct 110 ms 252940 KB Output is correct
5 Correct 113 ms 253012 KB Output is correct
6 Correct 110 ms 253092 KB Output is correct
7 Correct 111 ms 253012 KB Output is correct
8 Correct 111 ms 253016 KB Output is correct
9 Correct 110 ms 253012 KB Output is correct
10 Correct 114 ms 252804 KB Output is correct
11 Correct 109 ms 253008 KB Output is correct
12 Correct 112 ms 253008 KB Output is correct
13 Correct 109 ms 253016 KB Output is correct
14 Runtime error 248 ms 512712 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -