Submission #923298

#TimeUsernameProblemLanguageResultExecution timeMemory
923298vjudge1Maxcomp (info1cup18_maxcomp)C++17
15 / 100
1 ms4444 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx2") using namespace std; #define ll long long #define ld long double #define pb push_back #define pf push_front #define pii pair<int,int> #define all(v) v.begin(),v.end() #define F first #define S second #define mem(a,i) memset(a,i,sizeof(a)) #define sz(s) (int)s.size() #define int ll #define y1 yy #define maksim gay #define ppb pop_back #define gcd(a,b) __gcd(a,b) #define in insert const int dx[4]={-1,0,1,0}; const int dy[4]={0,-1,0,1}; const int inf=1e16; const int N=5e4+100; const int MAX=1010; const int mod=1e9+7; int n,m; int a[MAX][MAX]; int mn[MAX][MAX]; int mx[MAX][MAX]; void solve(){ cin>>n>>m; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>a[i][j]; } } for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){ mn[i][j]=-inf; mx[i][j]=-inf; } int ans=-inf; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ mn[i][j]=max(mn[i-1][j],mn[i][j-1]); mn[i][j]=max(mn[i][j],-a[i][j]+i+j-1); ans=max(ans,a[i][j]+mn[i][j]-i-j); } } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ mx[i][j]=max(mx[i-1][j],mx[i][j-1]); mx[i][j]=max(mx[i][j],a[i][j]+i+j-1); ans=max(ans,mx[i][j]-a[i][j]-i-j); } } cout<<ans<<"\n"; } main(){ // freopen("prizes.in", "r", stdin); // freopen("prizes.out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; // cin>>t; while(t--){ solve(); } }

Compilation message (stderr)

maxcomp.cpp:68:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   68 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...