이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
typedef unsigned long long ll;
#define pii pair<int,int>
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>>vec(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> vec[i][j];
}
}
int k;
cin >> k;
vector<pii>spe(k);
for (int i = 0; i < k; i++)
cin >> spe[i].first >> spe[i].second;
ll ans = 0;
for (int i = 0; i < k; i++) {
vector<int>vec1;
vec1.push_back(vec[spe[i].first][spe[i].second]);
vec1.push_back(vec[spe[i].first + 1][spe[i].second]);
vec1.push_back(vec[spe[i].first - 1][spe[i].second]);
vec1.push_back(vec[spe[i].first][spe[i].second + 1]);
vec1.push_back(vec[spe[i].first][spe[i].second - 1]);
sort(vec1.begin(), vec1.end());
for (int i = 4; i >= 1; i--) {
ans += vec1[i];
}
vec1.resize(0);
}
cout << ans;
}
# | 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... |