Submission #365733

#TimeUsernameProblemLanguageResultExecution timeMemory
365733mosiashvililukaMaxcomp (info1cup18_maxcomp)C++14
0 / 100
2 ms364 KiB
#include<bits/stdc++.h> using namespace std; int a,b,c,d,e,i,j,ii,jj,zx,xc,f[1009][1009],pas,fen[1009]; void upd(int q, int w){ while(q<=1002){ if(fen[q]<w) fen[q]=w; q=q+(q&(-q)); } } int read(int q){ int jm=-1010000000; while(q>=1){ if(jm<fen[q]) jm=fen[q]; q=q-(q&(-q)); } return jm; } int main(){ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); scanf("%d %d\n",&a,&b); for(i=1; i<=a; i++){ for(j=1; j<=b; j++){ if(j!=b) scanf("%d ",&f[i][j]); else scanf("%d",&f[i][j]); } if(i!=a) scanf("\n"); } for(i=1; i<=a; i++){ for(j=1; j<=b; j++){ for(ii=i; ii<=a; ii++){ for(jj=j; jj<=b; jj++){ if(f[ii][jj]>=f[i][j]){ if(pas<f[ii][jj]-f[i][j]-ii+i-jj+i-1){ pas=f[ii][jj]-f[i][j]-ii+i-jj+i-1; } }else{ if(pas<f[i][j]-f[ii][jj]-ii+i-jj+i-1){ pas=f[i][j]-f[ii][jj]-ii+i-jj+i-1; } } } } } } cout<<pas; return 0; //i+ j+ for(i=0; i<=1003; i++){ fen[i]=-1010000000; } for(i=1; i<=a; i++){ for(j=1; j<=b; j++){ c=read(j)+f[i][j]-i-j-1; pas=max(pas,c); upd(j,-f[i][j]+i+j); } } //i+ j- for(i=0; i<=1003; i++){ fen[i]=-1010000000; } for(i=1; i<=a; i++){ for(j=b; j>=1; j--){ c=read(b-j+1)+f[i][j]-i+j-1; pas=max(pas,c); upd(b-j+1,-f[i][j]+i-j); } } //cout<<pas<<endl; //i- j+ for(i=0; i<=1003; i++){ fen[i]=-1010000000; } for(j=1; j<=b; j++){ for(i=a; i>=1; i--){ c=read(a-i+1)+f[i][j]+i-j-1; pas=max(pas,c); upd(a-i+1,-f[i][j]-i+j); } } //cout<<pas<<endl; //i- j- for(i=0; i<=1003; i++){ fen[i]=-1010000000; } for(i=a; i>=1; i--){ for(j=b; j>=1; j--){ c=read(b-j+1)+f[i][j]+i+j-1; /*if(c==9){ cout<<i<<" qq "<<j<<endl; }*/ pas=max(pas,c); upd(b-j+1,-f[i][j]-i-j); } } cout<<pas; return 0; }

Compilation message (stderr)

maxcomp.cpp: In function 'int main()':
maxcomp.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |  scanf("%d %d\n",&a,&b);
      |  ~~~~~^~~~~~~~~~~~~~~~~
maxcomp.cpp:23:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |    if(j!=b) scanf("%d ",&f[i][j]); else scanf("%d",&f[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~
maxcomp.cpp:23:46: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |    if(j!=b) scanf("%d ",&f[i][j]); else scanf("%d",&f[i][j]);
      |                                         ~~~~~^~~~~~~~~~~~~~~
maxcomp.cpp:25:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |   if(i!=a) scanf("\n");
      |            ~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...