# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
365731 | 2021-02-12T09:36:20 Z | mosiashvililuka | Maxcomp (info1cup18_maxcomp) | C++14 | 1 ms | 364 KB |
#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"); } //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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Incorrect | 1 ms | 364 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Incorrect | 1 ms | 364 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Incorrect | 1 ms | 364 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |