Submission #364865

#TimeUsernameProblemLanguageResultExecution timeMemory
364865tengiz05Maxcomp (info1cup18_maxcomp)C++17
100 / 100
49 ms8192 KiB
#include <bits/stdc++.h> using namespace std; template <class T> inline void read(T &x) { x = 0; register char ch = getchar(); for (; ch<'0' || ch>'9';) ch = getchar(); for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar(); } //~ #define int long long #define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); #define all(x) (x).begin(), (x).end() #define pb push_back #define pii pair<int, int> #define ff first #define ss second #define PI acos(-1) #define ld long double template<class T> inline void chmin(T& a, const T& b) {if(a>b)a=b;} template<class T> inline void chmax(T& a, const T& b) {if(a<b)a=b;} const int mod = 1e9+7, N = 1005; int msb(int val){return sizeof(int)*8-__builtin_clzll(val)-1;} int n, m, k; int a[N][N]; int dp[N][N]; inline void solve(int test_case){ int i, j; read(n);read(m); memset(a, 245, sizeof a); for(i=1;i<=n;i++){ for(j=1;j<=m;j++){ read(a[i][j]); } } for(i=1;i<=n;i++){ for(j=1;j<=m;j++){ dp[i][j] = a[i][j]; chmax(dp[i][j], dp[i-1][j]-1); chmax(dp[i][j], dp[i][j-1]-1); } } for(i=n;i>=1;i--){ for(j=m;j>=1;j--){ chmax(dp[i][j],a[i][j]); chmax(dp[i][j], dp[i+1][j]-1); chmax(dp[i][j], dp[i][j+1]-1); } } int ans = -1; for(i=1;i<=n;i++){ for(j=1;j<=m;j++){ chmax(ans, dp[i][j] - a[i][j]); } } cout << ans-1 << '\n'; return; } /* 2 3 5 7 5 2 4 3 */ signed main(){ //~ FASTIO; //~ #define MULTITEST 1 #if MULTITEST int _T; cin >> _T; for(int T_CASE = 1; T_CASE <= _T; T_CASE++) solve(T_CASE); #else solve(1); #endif return 0; }

Compilation message (stderr)

maxcomp.cpp: In function 'void read(T&)':
maxcomp.cpp:4:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    4 |  x = 0; register char ch = getchar();
      |                       ^~
maxcomp.cpp: In instantiation of 'void read(T&) [with T = int]':
maxcomp.cpp:27:8:   required from here
maxcomp.cpp:4:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...