Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
- // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
- #include <iostream>
- #include <vector>
- #include <cmath>
- #include <algorithm>
- #include <set>
- #include <map>
- #include <queue>
- #include <random>
- #include <chrono>
- #include <cassert>
- #include <sstream>
- #include <fstream>
- #include <iomanip>
- #include <tuple>
- #define fi first
- #define se second
- #define pb push_back
- #define ll long long
- #define ld long double
- #define hm unordered_map
- #define pii pair<int, int>
- #define sz(a) (int)a.size()
- #define all(a) a.begin(), a.end()
- #define cinv(v) for (auto& x: v) cin >> x
- #define fr(i, n) for (int i = 0; i < (n); ++i)
- #define fl(i, l, n) for (int i = (l); i < (n); ++i)
- #define int ll
- template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1;} return 0;}
- template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1;} return 0;}
- using namespace std;
- #ifdef LOCAL
- #define dbg(x) cerr << #x << " : " << x << endl
- #else
- #define dbg(x)
- #endif
- //tg: @runningcherry
- template <typename Collection> string Join (const Collection& col) {
- bool first = true;
- stringstream ss;
- for (const auto& x: col) {
- if (!first) ss << ", ";
- first = false;
- ss << x;
- }
- return ss.str ();
- }
- template <typename T1, typename T2> ostream& operator << (ostream& out, const pair<T1, T2>& v) {
- return out << '{' << v.fi << ", " << v.se << '}';
- }
- template<typename T> ostream& operator << (ostream& out, const vector<T>& v) {
- return out << '[' << Join (v) << ']';
- }
- template <typename T1, typename T2> ostream& operator << (ostream& out, const map<T1, T2>& v) {
- return out << '{' << Join (v) << '}';
- }
- template<typename T> ostream& operator << (ostream& out, const set<T>& v) {
- return out << '(' << Join (v) << ')';
- }
- template<typename T> ostream& operator << (ostream& out, const multiset<T>& v) {
- return out << '(' << Join (v) << ')';
- }
- template <typename T1, typename T2> istream& operator >> (istream& in, pair<T1, T2>& a) {
- return in >> a.fi >> a.se;
- }
- const ll inf = (ll) 2e9;
- const ll mod = (ll)1e9 + 7;
- const int maxn = 2e5 + 20;
- mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
- const int n = 16;
- int goo[n][n];
- int dp[n][n];
- signed main () {
- ios_base::sync_with_stdio (false);
- cin.tie (nullptr);
- for (auto& v: goo) for (auto& x: v) cin >> x;
- fr (i, n) fr (j, n) {
- int mx = 0;
- if (i > 0) chkmax (mx, dp[i - 1][j]);
- if (j > 0) chkmax (mx, dp[i][j - 1]);
- if (i > 0 && j > 0) chkmax (mx, dp[i - 1][j - 1]);
- int f = 0;
- if (goo[i][j] % 3 == 0 && goo[i][j] <= 100) f = goo[i][j];
- else f = 40;
- dp[i][j] = mx + f;
- }
- cout << dp[n - 1][n - 1] << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement