# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
45254 | 2018-04-12T08:12:42 Z | ikura355 | Maxcomp (info1cup18_maxcomp) | C++14 | 274 ms | 67300 KB |
#include<bits/stdc++.h> using namespace std; const int maxn = 1e3 + 5; int n,m; long long p[maxn][maxn]; long long mx[maxn][maxn]; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%lld",&p[i][j]); long long ans = -1; for(int x=1;x<=n;x++) { for(int y=1;y<=m;y++) { mx[x][y] = -p[x][y] + x + y; if(y!=1) mx[x][y] = max(mx[x][y], mx[x][y-1]); if(x!=1) mx[x][y] = max(mx[x][y], mx[x-1][y]); ans = max(ans, p[x][y] - x - y + mx[x][y] - 1); } } for(int x=n;x>=1;x--) { for(int y=1;y<=m;y++) { mx[x][y] = -p[x][y] - x + y; if(y!=1) mx[x][y] = max(mx[x][y], mx[x][y-1]); if(x!=n) mx[x][y] = max(mx[x][y], mx[x+1][y]); ans = max(ans, p[x][y] + x - y + mx[x][y] - 1); } } for(int x=1;x<=n;x++) { for(int y=m;y>=1;y--) { mx[x][y] = -p[x][y] + x - y; if(y!=m) mx[x][y] = max(mx[x][y], mx[x][y+1]); if(x!=1) mx[x][y] = max(mx[x][y], mx[x-1][y]); ans = max(ans, p[x][y] - x + y + mx[x][y] - 1); } } for(int x=n;x>=1;x--) { for(int y=m;y>=1;y--) { mx[x][y] = -p[x][y] - x - y; if(y!=m) mx[x][y] = max(mx[x][y], mx[x][y+1]); if(x!=n) mx[x][y] = max(mx[x][y], mx[x+1][y]); ans = max(ans, p[x][y] + x + y + mx[x][y] - 1); } } printf("%lld",ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 252 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 408 KB | Output is correct |
4 | Correct | 2 ms | 484 KB | Output is correct |
5 | Correct | 2 ms | 484 KB | Output is correct |
6 | Correct | 2 ms | 532 KB | Output is correct |
7 | Correct | 3 ms | 544 KB | Output is correct |
8 | Correct | 2 ms | 544 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 592 KB | Output is correct |
2 | Correct | 2 ms | 720 KB | Output is correct |
3 | Correct | 2 ms | 720 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 252 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 408 KB | Output is correct |
4 | Correct | 2 ms | 484 KB | Output is correct |
5 | Correct | 2 ms | 484 KB | Output is correct |
6 | Correct | 2 ms | 532 KB | Output is correct |
7 | Correct | 3 ms | 544 KB | Output is correct |
8 | Correct | 2 ms | 544 KB | Output is correct |
9 | Correct | 2 ms | 996 KB | Output is correct |
10 | Correct | 3 ms | 996 KB | Output is correct |
11 | Correct | 3 ms | 1004 KB | Output is correct |
12 | Correct | 2 ms | 1004 KB | Output is correct |
13 | Correct | 3 ms | 1004 KB | Output is correct |
14 | Correct | 2 ms | 1004 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 252 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 408 KB | Output is correct |
4 | Correct | 2 ms | 484 KB | Output is correct |
5 | Correct | 2 ms | 484 KB | Output is correct |
6 | Correct | 2 ms | 532 KB | Output is correct |
7 | Correct | 3 ms | 544 KB | Output is correct |
8 | Correct | 2 ms | 544 KB | Output is correct |
9 | Correct | 2 ms | 592 KB | Output is correct |
10 | Correct | 2 ms | 720 KB | Output is correct |
11 | Correct | 2 ms | 720 KB | Output is correct |
12 | Correct | 2 ms | 996 KB | Output is correct |
13 | Correct | 3 ms | 996 KB | Output is correct |
14 | Correct | 3 ms | 1004 KB | Output is correct |
15 | Correct | 2 ms | 1004 KB | Output is correct |
16 | Correct | 3 ms | 1004 KB | Output is correct |
17 | Correct | 2 ms | 1004 KB | Output is correct |
18 | Correct | 274 ms | 16320 KB | Output is correct |
19 | Correct | 226 ms | 24960 KB | Output is correct |
20 | Correct | 251 ms | 33136 KB | Output is correct |
21 | Correct | 212 ms | 41668 KB | Output is correct |
22 | Correct | 233 ms | 50268 KB | Output is correct |
23 | Correct | 239 ms | 58856 KB | Output is correct |
24 | Correct | 170 ms | 67300 KB | Output is correct |