# | Submission time^{} |
Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|

997157 | 2024-06-11T18:24:07 Z | vladilius | Team Contest (JOI22_team) | C++17 | 2000 ms | 14124 KB |

#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second #define ins insert #define arr3 array<int, 3> int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; vector<arr3> f = {{}}; map<arr3, bool> mp; for (int i = 1; i <= n; i++){ arr3 d; cin>>d[0]>>d[1]>>d[2]; if (mp.find(d) == mp.end()){ f.pb(d); mp[d] = 1; } } n = (int) f.size() - 1; sort(f.begin() + 1, f.end()); vector<int> a(n + 1, -1); int i = 1, out = -1; while (i <= n){ int j = i; while (j <= n && f[i][0] == f[j][0]){ j++; } int mx = -1; for (int t = i; t < j; t++){ for (int k = 1; k < i; k++){ if (a[k] == -1) continue; if (f[k][1] > f[t][1] && (a[k] - f[k][1]) > f[t][2]){ mx = max(mx, a[k]); } } } for (int t = i; t < j; t++){ for (int k = 1; k < j; k++){ if (f[k][1] > f[t][1] && f[k][2] < f[t][2]){ a[k] = max(a[k], f[k][1] + f[t][2]); } if (f[t][1] > f[k][1] && f[t][2] < f[k][2]){ a[t] = max(a[t], f[t][1] + f[k][2]); } } } if (mx != -1) out = max(out, f[i][0] + mx); i = j; } cout<<out<<"\n"; }

# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|

1 | Correct | 0 ms | 344 KB | Output is correct |

2 | Correct | 0 ms | 348 KB | Output is correct |

3 | Correct | 1 ms | 344 KB | Output is correct |

4 | Correct | 0 ms | 348 KB | Output is correct |

5 | Correct | 0 ms | 348 KB | Output is correct |

6 | Correct | 0 ms | 348 KB | Output is correct |

7 | Correct | 0 ms | 600 KB | Output is correct |

8 | Correct | 0 ms | 452 KB | Output is correct |

9 | Correct | 1 ms | 348 KB | Output is correct |

10 | Correct | 1 ms | 348 KB | Output is correct |

11 | Correct | 0 ms | 344 KB | Output is correct |

12 | Correct | 1 ms | 344 KB | Output is correct |

13 | Correct | 0 ms | 348 KB | Output is correct |

14 | Correct | 1 ms | 348 KB | Output is correct |

15 | Correct | 0 ms | 348 KB | Output is correct |

16 | Correct | 0 ms | 348 KB | Output is correct |

17 | Correct | 1 ms | 348 KB | Output is correct |

18 | Correct | 1 ms | 348 KB | Output is correct |

19 | Correct | 2 ms | 348 KB | Output is correct |

20 | Correct | 1 ms | 344 KB | Output is correct |

21 | Correct | 1 ms | 456 KB | Output is correct |

22 | Correct | 0 ms | 348 KB | Output is correct |

23 | Correct | 0 ms | 348 KB | Output is correct |

24 | Correct | 0 ms | 348 KB | Output is correct |

25 | Correct | 0 ms | 348 KB | Output is correct |

# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|

1 | Correct | 0 ms | 344 KB | Output is correct |

2 | Correct | 0 ms | 348 KB | Output is correct |

3 | Correct | 1 ms | 344 KB | Output is correct |

4 | Correct | 0 ms | 348 KB | Output is correct |

5 | Correct | 0 ms | 348 KB | Output is correct |

6 | Correct | 0 ms | 348 KB | Output is correct |

7 | Correct | 0 ms | 600 KB | Output is correct |

8 | Correct | 0 ms | 452 KB | Output is correct |

9 | Correct | 1 ms | 348 KB | Output is correct |

10 | Correct | 1 ms | 348 KB | Output is correct |

11 | Correct | 0 ms | 344 KB | Output is correct |

12 | Correct | 1 ms | 344 KB | Output is correct |

13 | Correct | 0 ms | 348 KB | Output is correct |

14 | Correct | 1 ms | 348 KB | Output is correct |

15 | Correct | 0 ms | 348 KB | Output is correct |

16 | Correct | 0 ms | 348 KB | Output is correct |

17 | Correct | 1 ms | 348 KB | Output is correct |

18 | Correct | 1 ms | 348 KB | Output is correct |

19 | Correct | 2 ms | 348 KB | Output is correct |

20 | Correct | 1 ms | 344 KB | Output is correct |

21 | Correct | 1 ms | 456 KB | Output is correct |

22 | Correct | 0 ms | 348 KB | Output is correct |

23 | Correct | 0 ms | 348 KB | Output is correct |

24 | Correct | 0 ms | 348 KB | Output is correct |

25 | Correct | 0 ms | 348 KB | Output is correct |

26 | Correct | 59 ms | 860 KB | Output is correct |

27 | Correct | 58 ms | 860 KB | Output is correct |

28 | Correct | 42 ms | 860 KB | Output is correct |

29 | Correct | 28 ms | 856 KB | Output is correct |

30 | Correct | 18 ms | 604 KB | Output is correct |

31 | Correct | 51 ms | 796 KB | Output is correct |

32 | Correct | 25 ms | 604 KB | Output is correct |

33 | Correct | 10 ms | 604 KB | Output is correct |

34 | Correct | 16 ms | 860 KB | Output is correct |

35 | Correct | 1 ms | 348 KB | Output is correct |

36 | Correct | 1 ms | 348 KB | Output is correct |

37 | Correct | 21 ms | 1116 KB | Output is correct |

38 | Correct | 16 ms | 600 KB | Output is correct |

39 | Correct | 9 ms | 612 KB | Output is correct |

# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|

1 | Correct | 1 ms | 348 KB | Output is correct |

2 | Correct | 1 ms | 348 KB | Output is correct |

3 | Correct | 0 ms | 348 KB | Output is correct |

4 | Correct | 0 ms | 348 KB | Output is correct |

5 | Correct | 0 ms | 344 KB | Output is correct |

6 | Correct | 1 ms | 344 KB | Output is correct |

7 | Correct | 1 ms | 348 KB | Output is correct |

8 | Correct | 0 ms | 348 KB | Output is correct |

9 | Correct | 0 ms | 348 KB | Output is correct |

10 | Correct | 0 ms | 348 KB | Output is correct |

11 | Correct | 21 ms | 1116 KB | Output is correct |

12 | Correct | 13 ms | 860 KB | Output is correct |

13 | Correct | 14 ms | 1112 KB | Output is correct |

14 | Correct | 19 ms | 1116 KB | Output is correct |

15 | Correct | 18 ms | 1116 KB | Output is correct |

16 | Correct | 15 ms | 1116 KB | Output is correct |

# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|

1 | Correct | 1 ms | 348 KB | Output is correct |

2 | Correct | 1 ms | 348 KB | Output is correct |

3 | Correct | 0 ms | 348 KB | Output is correct |

4 | Correct | 0 ms | 348 KB | Output is correct |

5 | Correct | 0 ms | 344 KB | Output is correct |

6 | Correct | 1 ms | 344 KB | Output is correct |

7 | Correct | 1 ms | 348 KB | Output is correct |

8 | Correct | 0 ms | 348 KB | Output is correct |

9 | Correct | 0 ms | 348 KB | Output is correct |

10 | Correct | 0 ms | 348 KB | Output is correct |

11 | Correct | 21 ms | 1116 KB | Output is correct |

12 | Correct | 13 ms | 860 KB | Output is correct |

13 | Correct | 14 ms | 1112 KB | Output is correct |

14 | Correct | 19 ms | 1116 KB | Output is correct |

15 | Correct | 18 ms | 1116 KB | Output is correct |

16 | Correct | 15 ms | 1116 KB | Output is correct |

17 | Correct | 0 ms | 348 KB | Output is correct |

18 | Correct | 0 ms | 348 KB | Output is correct |

19 | Correct | 0 ms | 348 KB | Output is correct |

20 | Correct | 0 ms | 348 KB | Output is correct |

21 | Correct | 7 ms | 612 KB | Output is correct |

22 | Correct | 103 ms | 2064 KB | Output is correct |

23 | Correct | 32 ms | 1368 KB | Output is correct |

24 | Correct | 21 ms | 1112 KB | Output is correct |

25 | Correct | 27 ms | 1628 KB | Output is correct |

26 | Correct | 18 ms | 1368 KB | Output is correct |

# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|

1 | Correct | 1 ms | 348 KB | Output is correct |

2 | Correct | 1 ms | 348 KB | Output is correct |

3 | Correct | 0 ms | 348 KB | Output is correct |

4 | Correct | 0 ms | 348 KB | Output is correct |

5 | Correct | 0 ms | 344 KB | Output is correct |

6 | Correct | 1 ms | 344 KB | Output is correct |

7 | Correct | 1 ms | 348 KB | Output is correct |

8 | Correct | 0 ms | 348 KB | Output is correct |

9 | Correct | 0 ms | 348 KB | Output is correct |

10 | Correct | 0 ms | 348 KB | Output is correct |

11 | Correct | 21 ms | 1116 KB | Output is correct |

12 | Correct | 13 ms | 860 KB | Output is correct |

13 | Correct | 14 ms | 1112 KB | Output is correct |

14 | Correct | 19 ms | 1116 KB | Output is correct |

15 | Correct | 18 ms | 1116 KB | Output is correct |

16 | Correct | 15 ms | 1116 KB | Output is correct |

17 | Correct | 0 ms | 348 KB | Output is correct |

18 | Correct | 0 ms | 348 KB | Output is correct |

19 | Correct | 0 ms | 348 KB | Output is correct |

20 | Correct | 0 ms | 348 KB | Output is correct |

21 | Correct | 7 ms | 612 KB | Output is correct |

22 | Correct | 103 ms | 2064 KB | Output is correct |

23 | Correct | 32 ms | 1368 KB | Output is correct |

24 | Correct | 21 ms | 1112 KB | Output is correct |

25 | Correct | 27 ms | 1628 KB | Output is correct |

26 | Correct | 18 ms | 1368 KB | Output is correct |

27 | Correct | 1 ms | 348 KB | Output is correct |

28 | Correct | 1 ms | 348 KB | Output is correct |

29 | Correct | 0 ms | 348 KB | Output is correct |

30 | Correct | 0 ms | 348 KB | Output is correct |

31 | Correct | 29 ms | 604 KB | Output is correct |

32 | Correct | 1 ms | 348 KB | Output is correct |

33 | Correct | 1 ms | 348 KB | Output is correct |

34 | Execution timed out | 2097 ms | 14124 KB | Time limit exceeded |

35 | Halted | 0 ms | 0 KB | - |

# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|

1 | Correct | 1 ms | 348 KB | Output is correct |

2 | Correct | 1 ms | 348 KB | Output is correct |

3 | Correct | 0 ms | 348 KB | Output is correct |

4 | Correct | 0 ms | 348 KB | Output is correct |

5 | Correct | 0 ms | 344 KB | Output is correct |

6 | Correct | 1 ms | 344 KB | Output is correct |

7 | Correct | 1 ms | 348 KB | Output is correct |

8 | Correct | 0 ms | 348 KB | Output is correct |

9 | Correct | 0 ms | 348 KB | Output is correct |

10 | Correct | 0 ms | 348 KB | Output is correct |

11 | Correct | 21 ms | 1116 KB | Output is correct |

12 | Correct | 13 ms | 860 KB | Output is correct |

13 | Correct | 14 ms | 1112 KB | Output is correct |

14 | Correct | 19 ms | 1116 KB | Output is correct |

15 | Correct | 18 ms | 1116 KB | Output is correct |

16 | Correct | 15 ms | 1116 KB | Output is correct |

17 | Correct | 0 ms | 348 KB | Output is correct |

18 | Correct | 0 ms | 348 KB | Output is correct |

19 | Correct | 0 ms | 348 KB | Output is correct |

20 | Correct | 0 ms | 348 KB | Output is correct |

21 | Correct | 7 ms | 612 KB | Output is correct |

22 | Correct | 103 ms | 2064 KB | Output is correct |

23 | Correct | 32 ms | 1368 KB | Output is correct |

24 | Correct | 21 ms | 1112 KB | Output is correct |

25 | Correct | 27 ms | 1628 KB | Output is correct |

26 | Correct | 18 ms | 1368 KB | Output is correct |

27 | Correct | 1 ms | 348 KB | Output is correct |

28 | Correct | 1 ms | 348 KB | Output is correct |

29 | Correct | 0 ms | 348 KB | Output is correct |

30 | Correct | 0 ms | 348 KB | Output is correct |

31 | Correct | 29 ms | 604 KB | Output is correct |

32 | Correct | 1 ms | 348 KB | Output is correct |

33 | Correct | 1 ms | 348 KB | Output is correct |

34 | Execution timed out | 2097 ms | 14124 KB | Time limit exceeded |

35 | Halted | 0 ms | 0 KB | - |

# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|

1 | Correct | 0 ms | 344 KB | Output is correct |

2 | Correct | 0 ms | 348 KB | Output is correct |

3 | Correct | 1 ms | 344 KB | Output is correct |

4 | Correct | 0 ms | 348 KB | Output is correct |

5 | Correct | 0 ms | 348 KB | Output is correct |

6 | Correct | 0 ms | 348 KB | Output is correct |

7 | Correct | 0 ms | 600 KB | Output is correct |

8 | Correct | 0 ms | 452 KB | Output is correct |

9 | Correct | 1 ms | 348 KB | Output is correct |

10 | Correct | 1 ms | 348 KB | Output is correct |

11 | Correct | 0 ms | 344 KB | Output is correct |

12 | Correct | 1 ms | 344 KB | Output is correct |

13 | Correct | 0 ms | 348 KB | Output is correct |

14 | Correct | 1 ms | 348 KB | Output is correct |

15 | Correct | 0 ms | 348 KB | Output is correct |

16 | Correct | 0 ms | 348 KB | Output is correct |

17 | Correct | 1 ms | 348 KB | Output is correct |

18 | Correct | 1 ms | 348 KB | Output is correct |

19 | Correct | 2 ms | 348 KB | Output is correct |

20 | Correct | 1 ms | 344 KB | Output is correct |

21 | Correct | 1 ms | 456 KB | Output is correct |

22 | Correct | 0 ms | 348 KB | Output is correct |

23 | Correct | 0 ms | 348 KB | Output is correct |

24 | Correct | 0 ms | 348 KB | Output is correct |

25 | Correct | 0 ms | 348 KB | Output is correct |

26 | Correct | 59 ms | 860 KB | Output is correct |

27 | Correct | 58 ms | 860 KB | Output is correct |

28 | Correct | 42 ms | 860 KB | Output is correct |

29 | Correct | 28 ms | 856 KB | Output is correct |

30 | Correct | 18 ms | 604 KB | Output is correct |

31 | Correct | 51 ms | 796 KB | Output is correct |

32 | Correct | 25 ms | 604 KB | Output is correct |

33 | Correct | 10 ms | 604 KB | Output is correct |

34 | Correct | 16 ms | 860 KB | Output is correct |

35 | Correct | 1 ms | 348 KB | Output is correct |

36 | Correct | 1 ms | 348 KB | Output is correct |

37 | Correct | 21 ms | 1116 KB | Output is correct |

38 | Correct | 16 ms | 600 KB | Output is correct |

39 | Correct | 9 ms | 612 KB | Output is correct |

40 | Correct | 1 ms | 348 KB | Output is correct |

41 | Correct | 1 ms | 348 KB | Output is correct |

42 | Correct | 0 ms | 348 KB | Output is correct |

43 | Correct | 0 ms | 348 KB | Output is correct |

44 | Correct | 0 ms | 344 KB | Output is correct |

45 | Correct | 1 ms | 344 KB | Output is correct |

46 | Correct | 1 ms | 348 KB | Output is correct |

47 | Correct | 0 ms | 348 KB | Output is correct |

48 | Correct | 0 ms | 348 KB | Output is correct |

49 | Correct | 0 ms | 348 KB | Output is correct |

50 | Correct | 21 ms | 1116 KB | Output is correct |

51 | Correct | 13 ms | 860 KB | Output is correct |

52 | Correct | 14 ms | 1112 KB | Output is correct |

53 | Correct | 19 ms | 1116 KB | Output is correct |

54 | Correct | 18 ms | 1116 KB | Output is correct |

55 | Correct | 15 ms | 1116 KB | Output is correct |

56 | Correct | 0 ms | 348 KB | Output is correct |

57 | Correct | 0 ms | 348 KB | Output is correct |

58 | Correct | 0 ms | 348 KB | Output is correct |

59 | Correct | 0 ms | 348 KB | Output is correct |

60 | Correct | 7 ms | 612 KB | Output is correct |

61 | Correct | 103 ms | 2064 KB | Output is correct |

62 | Correct | 32 ms | 1368 KB | Output is correct |

63 | Correct | 21 ms | 1112 KB | Output is correct |

64 | Correct | 27 ms | 1628 KB | Output is correct |

65 | Correct | 18 ms | 1368 KB | Output is correct |

66 | Correct | 1 ms | 348 KB | Output is correct |

67 | Correct | 1 ms | 348 KB | Output is correct |

68 | Correct | 0 ms | 348 KB | Output is correct |

69 | Correct | 0 ms | 348 KB | Output is correct |

70 | Correct | 29 ms | 604 KB | Output is correct |

71 | Correct | 1 ms | 348 KB | Output is correct |

72 | Correct | 1 ms | 348 KB | Output is correct |

73 | Execution timed out | 2097 ms | 14124 KB | Time limit exceeded |

74 | Halted | 0 ms | 0 KB | - |