题目:
代码:
class Solution {
public:
int projectionArea(vector<vector<int>>& grid) {
int n=grid.size();
int memi[n],memj[n];
for(int i=0;i<n;i++){
memi[i]=0;
memj[i]=0;
}
int ans=0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(grid[i][j]>0) {
ans++;
if(grid[i][j]>memi[i]) memi[i]=grid[i][j];
if(grid[i][j]>memj[j]) memj[j]=grid[i][j];
}
}
}
for(int i=0;i<n;i++){
ans=ans+memi[i]+memj[i];
}
return ans;
}
};