Submission #464522

#TimeUsernameProblemLanguageResultExecution timeMemory
464522kilikumaT-Covering (eJOI19_covering)C++14
5 / 100
247 ms8184 KiB
#include <bits/stdc++.h> using namespace std; long long m,n,k,x,y; int main(){ cin>>n>>m; long long grille[n+5][m+5]; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { cin>>grille[i][j]; } } long long res=0; cin>>k; while(k--){ cin>>x>>y; res=res+grille[x][y]; long long maxiCur=-1; if(x-1>=0&&y+1<m&&y-1>=0){ maxiCur=max(maxiCur,grille[x-1][y]+grille[x][y+1]+grille[x][y-1]); } if(x-1>=0&&y-1>=0&&x+1<n){ maxiCur=max(maxiCur,grille[x-1][y]+grille[x+1][y]+grille[x][y-1]); } if(x-1>=0&&x+1<n&&y+1<m){ maxiCur=max(maxiCur,grille[x-1][y]+grille[x+1][y]+grille[x][y+1]); } if(y+1<m&&y-1>=0&&x+1<n){ maxiCur=max(maxiCur,grille[x][y+1]+grille[x][y-1]+grille[x+1][y]); } if(maxiCur==-1){ cout<<"No"<<endl; return 0; } res=res+maxiCur; } cout<<res<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...