제출 #523631

#제출 시각아이디문제언어결과실행 시간메모리
523631maks007Maxcomp (info1cup18_maxcomp)C++14
0 / 100
323 ms296 KiB
#include <bits/stdc++.h> using namespace std; int main(void) { int n, m; cin >> n >> m; vector <vector <int>> a(n, vector <int> (m, -1)); int mx = -1e9; int mn = 1e9; pair <int,int> mxid, mnid; for(int i = 0; i < n; i ++) { for(int j = 0; j < m; j ++) { cin >> a[i][j]; /*if(g[i][j] > mx) { mx = g[i][j]; mxid = {i, j}; } if(g[i][j] < mn) { mn = g[i][j]; mnid = {i, j}; }*/ } } // cout << mx - mn - (abs(mnid.first - mxid.first) + abs(mxid.second - mnid.second) + 1); int ans = 1e9; for(int i = 0; i < m; i ++) { for(int j = i + 1; j < m; j ++) { ans = min(ans, *max_element(a[0].begin()+i, a[0].begin()+j+1) - *min_element(a[0].begin()+i, a[0].begin()+j+1) - (j-i+1)); } } cout << ans; return false; }

컴파일 시 표준 에러 (stderr) 메시지

maxcomp.cpp: In function 'int main()':
maxcomp.cpp:9:6: warning: unused variable 'mx' [-Wunused-variable]
    9 |  int mx = -1e9;
      |      ^~
maxcomp.cpp:10:6: warning: unused variable 'mn' [-Wunused-variable]
   10 |  int mn = 1e9;
      |      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...