Advertisement
Galebickosikasa

Untitled

May 11th, 2021
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. // #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
  2. // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
  3.  
  4. #include <iostream>
  5. #include <vector>
  6. #include <cmath>
  7. #include <algorithm>
  8. #include <set>
  9. #include <map>
  10. #include <queue>
  11. #include <random>
  12. #include <chrono>
  13. #include <cassert>
  14. #include <sstream>
  15. #include <fstream>
  16. #include <iomanip>
  17. #include <tuple>
  18.  
  19. #define fi first
  20. #define se second
  21. #define pb push_back
  22. #define ll long long
  23. #define ld long double
  24. #define hm unordered_map
  25. #define pii pair<int, int>
  26. #define sz(a) (int)a.size()
  27. #define all(a) a.begin(), a.end()
  28. #define cinv(v) for (auto& x: v) cin >> x
  29. #define fr(i, n) for (int i = 0; i < (n); ++i)
  30. #define fl(i, l, n) for (int i = (l); i < (n); ++i)
  31.  
  32. #define int ll
  33.  
  34. template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1;} return 0;}
  35. template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1;} return 0;}
  36.  
  37. using namespace std;
  38.  
  39. #ifdef LOCAL
  40. #define dbg(x) cerr << #x << " : " << x << endl
  41. #else
  42. #define dbg(x)
  43. #endif
  44.  
  45. //tg: @runningcherry
  46.  
  47. template <typename Collection> string Join (const Collection& col) {
  48. bool first = true;
  49. stringstream ss;
  50. for (const auto& x: col) {
  51. if (!first) ss << ", ";
  52. first = false;
  53. ss << x;
  54. }
  55. return ss.str ();
  56. }
  57.  
  58. template <typename T1, typename T2> ostream& operator << (ostream& out, const pair<T1, T2>& v) {
  59. return out << '{' << v.fi << ", " << v.se << '}';
  60. }
  61.  
  62. template<typename T> ostream& operator << (ostream& out, const vector<T>& v) {
  63. return out << '[' << Join (v) << ']';
  64. }
  65.  
  66. template <typename T1, typename T2> ostream& operator << (ostream& out, const map<T1, T2>& v) {
  67. return out << '{' << Join (v) << '}';
  68. }
  69.  
  70. template<typename T> ostream& operator << (ostream& out, const set<T>& v) {
  71. return out << '(' << Join (v) << ')';
  72. }
  73.  
  74. template<typename T> ostream& operator << (ostream& out, const multiset<T>& v) {
  75. return out << '(' << Join (v) << ')';
  76. }
  77.  
  78. template <typename T1, typename T2> istream& operator >> (istream& in, pair<T1, T2>& a) {
  79. return in >> a.fi >> a.se;
  80. }
  81.  
  82. const ll inf = (ll) 2e9;
  83. const ll mod = (ll)1e9 + 7;
  84.  
  85. const int maxn = 2e5 + 20;
  86.  
  87. mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
  88.  
  89. const int n = 16;
  90. int goo[n][n];
  91. int dp[n][n];
  92.  
  93. signed main () {
  94. ios_base::sync_with_stdio (false);
  95. cin.tie (nullptr);
  96. for (auto& v: goo) for (auto& x: v) cin >> x;
  97.  
  98. fr (i, n) fr (j, n) {
  99. int mx = 0;
  100. if (i > 0) chkmax (mx, dp[i - 1][j]);
  101. if (j > 0) chkmax (mx, dp[i][j - 1]);
  102. if (i > 0 && j > 0) chkmax (mx, dp[i - 1][j - 1]);
  103. int f = 0;
  104. if (goo[i][j] % 3 == 0 && goo[i][j] <= 100) f = goo[i][j];
  105. else f = 40;
  106. dp[i][j] = mx + f;
  107. }
  108. cout << dp[n - 1][n - 1] << '\n';
  109.  
  110.  
  111.  
  112.  
  113. }
  114.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement