답안 #523717

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
523717 2022-02-08T04:57:58 Z maks007 Maxcomp (info1cup18_maxcomp) C++14
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
 
using namespace std;
 
int dis(pair <int,int>a, pair <int,int> b) {
	return abs(a.first - b.first) + abs(a.second - b.second);
}
 
int main(void) {
	int n, m;
	cin >> n >> m;
	
	vector <vector <int> > g(n, vector <int> (m));
	
	
	for(int i  = 0; i < n; i ++) {
		for(int j = 0; j < m; j ++) cin >> g[i][j];
	}

	int ans = -1e9;
	int mx = -1e9;
	int i, j;
	for(int k = 0; k < n; k ++) {
		for(int l = 0; l < m; l ++) {
			if(g[k][l] > mx) {
				mx = g[k][l];
				i = k;
				j = l;
			}
		}
	}
 
			for(int k = 0; k < n; k ++) {
				for(int l = 0; l < m; l ++) {

					ans = max(ans, g[i][j] - g[k][l] - (abs(i-k)+abs(j-l)+1));
				}
			}
	
	cout << ans;
	return false;
}

Compilation message

maxcomp.cpp: In function 'int main()':
maxcomp.cpp:22:9: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |  int i, j;
      |         ^
maxcomp.cpp:22:6: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |  int i, j;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -