이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mid (start+end)/2
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
//bana beş puan ver
bool stop=true;
int32_t main(){
faster
int n,m;cin>>n>>m;
int dizi[n+1][m+1];
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>dizi[i][j];
}
}
int k;cin>>k;
int ans=0;
for(int i=0;i<k;i++){
int a,b;cin>>a>>b;
a++;b++;
if(a<=0 || b<=0 || a>n || b>m){
stop=false;
}
int maxi=0,cev1=0,cev2=0;
int ort=dizi[a][b];
int ust=0,alt=0,sag=0,sol=0;
if(a+1<=n)ust=dizi[a+1][b];
if(a-1>0)alt=dizi[a-1][b];
if(b+1<=m)sag=dizi[a][b+1];
if(b-1>0)sol=dizi[a][b-1];
cev1=max(alt,ust)+sag+sol;
cev2=max(sag,sol)+alt+ust;
maxi=max(cev1,cev2);
ans+=maxi+ort;
}
if(stop)cout<<ans<<'\n';
else cout<<"No"<<'\n';
return 0;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |