제출 #949181

#제출 시각아이디문제언어결과실행 시간메모리
949181vjudge1Best Place (NOI17_bestplace)C++17
100 / 100
32 ms2136 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define ff first #define ss second #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define sz(v) (int)v.size() const int INF = 1e18; const int mod = 998244353; const int N = 1e5+5; void solve(){ int n; cin >> n; vector<int> x(n), y(n); for(int i = 0; i < n; i++){ cin >> x[i] >> y[i]; } int l = 0, r = 1e9; int xans = 0; while(l <= r){ int m1 = l + (r - l) / 3; int m2 = r - (r - l) / 3; int res1 = 0, res2 = 0; for(int i = 0; i < n; i++){ res1 += abs(m1 - x[i]); res2 += abs(m2 - x[i]); } if(res1 < res2){ r = m2 - 1; xans = m1; }else{ l = m1 + 1; xans = m2; } } l = 0; r = 1e9; int yans = 0; while(l <= r){ int m1 = l + (r - l) / 3; int m2 = r - (r - l) / 3; int res1 = 0, res2 = 0; for(int i = 0; i < n; i++){ res1 += abs(m1 - y[i]); res2 += abs(m2 - y[i]); } if(res1 < res2){ r = m2 - 1; yans = m1; }else{ l = m1 + 1; yans = m2; } } cout << xans << ' ' << yans; } main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tt = 1; //cin >> tt; while (tt--) { solve(); } }

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

bestplace.cpp:65:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   65 | main(){
      | ^~~~
#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...