# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
365731 | mosiashvililuka | Maxcomp (info1cup18_maxcomp) | C++14 | 1 ms | 364 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |