제출 #987873

#제출 시각아이디문제언어결과실행 시간메모리
987873AcanikolicBest Place (NOI17_bestplace)C++14
3 / 100
17 ms3164 KiB
#include <bits/stdc++.h> #define pb push_back #define S second #define F first const int N = 1e5 + 10; const int inf = 2e9; using namespace std; int x[N],y[N],n; int dist(int x1,int y1,int x2,int y2) { return abs(x1 - x2) + abs(y1 - y2); } int solve(int X,int Y) { int res = 0; for(int i = 1; i <= n; i++) res += abs(x[i] - X) + abs(y[i] - Y); return res; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; int smX = 0,smY = 0; for(int i = 1; i <= n; i++) { cin >> x[i] >> y[i]; smX += x[i]; smY += y[i]; } int Q1 = smX / n,Q2 = (smX + n - 1) / n,W1 = smY / n,W2 = (smY + n - 1) / n; int res = solve(Q1,W1); res = min(res,solve(Q1,W2)); res = min(res,solve(Q2,W1)); res = min(res,solve(Q2,W2)); int rezX,rezY; if(res == solve(Q1,W1)) { rezX = Q1; rezY = W1; }else if(res == solve(Q1,W2)) { rezX = Q1; rezY = W2; }else if(res == solve(Q2,W1)) { rezX = Q2; rezY = W1; }else if(res == solve(Q2,W2)) { rezX = Q2; rezY = W2; } cout << rezX << " " << rezY; return 0; }

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

bestplace.cpp: In function 'int main()':
bestplace.cpp:57:28: warning: 'rezY' may be used uninitialized in this function [-Wmaybe-uninitialized]
   57 |     cout << rezX << " " << rezY;
      |                            ^~~~
bestplace.cpp:57:21: warning: 'rezX' may be used uninitialized in this function [-Wmaybe-uninitialized]
   57 |     cout << rezX << " " << rezY;
      |                     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...