| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 359965 | Poimidorka | Maxcomp (info1cup18_maxcomp) | C++14 | 2 ms | 620 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <queue>
#include <string>
#include <algorithm>
#include <tuple>
#include <cassert>
using namespace std;
#define x first
#define y second
#define int long long
const int maxn = 1e3 + 10;
int mat[maxn][maxn];
int opt[maxn][maxn];
vector<pair<int, int>> dir = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}};
int n, m;
bool check(int x, int y) {
return x >= 0 && y >= 0 && x < n && y < m;
}
signed main() {
#ifdef LC
assert(freopen("input.txt", "r", stdin));
#endif
ios::sync_with_stdio(0); cin.tie(0);
vector<pair<int, pair<int, int>>> v;
cin >> n >> m;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> mat[i][j];
v.push_back({mat[i][j], {i, j}});
}
}
int ans = -1;
sort(v.rbegin(), v.rend());
for (int i = 0; i < v.size(); i++) {
int x = v[i].y.x;
int y = v[i].y.y;
opt[x][y] = -1;
for (auto el : dir) {
int x2 = el.x + x;
int y2 = el.y + y;
if (!check(x2, y2) || mat[x2][y2] <= mat[x][y])
continue;
opt[x][y] = max(opt[x][y], opt[x2][y2] - 1 + mat[x2][y2] - mat[x][y]);
opt[x][y] = max(opt[x][y], mat[x2][y2] - mat[x][y] - 2);
ans = max(ans, opt[x][y]);
}
}
assert(ans != -1);
cout << ans;
return 0;
}컴파일 시 표준 에러 (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... | ||||
