Submission #949187

#TimeUsernameProblemLanguageResultExecution timeMemory
949187vjudge1Best Place (NOI17_bestplace)C++17
16 / 100
1055 ms1884 KiB
///* __ __ __ */ ///* ====== _ /| /| __ _ / | | /| | * | | | | / /| |\ | / | | * | / */ ///* \- || |_| |_ / |/ | | | |_ |- | |--| /-| | | \ \ |==| |- /=| | \ | | |--| | |- */ ///* || | | |_ / | |__| _| |_ \__ | | / | |__ | __| | | | \ / | | \| \__ | | | | \ */ ///* // autor :: Rick Prime #include <bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second #define all(x) x.begin(),x.end() #define int long long typedef vector<int> vi; typedef vector<double> vd; typedef pair<int,int> pii; typedef vector<pii> vii; //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //using namespace __gnu_pbds; //#define order_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> const int N = 1e7, inf = 1e9, mod = 1e9+7; void solve(){ int n; cin >> n; int x = 0, y = 0; int a[n], b[n]; for(int i = 0; i < n; i++){ cin >> a[i] >> b[i]; x += a[i]; y += b[i]; } x/=n; y/=n; int ans = 0; int ax = x, ay = y; for(int i = 0; i < n; i++){ ans += abs(a[i] - x) + abs(b[i] - y); } for(int i = x-50; i <= x+50; i++){ for(int j = y-50; j <= y+50; j++){ int res = 0; for(int k = 0; k < n; k++){ res += abs(a[k] - i) + abs(b[k] - j); } if(res <= ans){ ans = res; ax = i; ay = j; } } } cout << ax << ' ' << ay << '\n'; } main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int test = 1; //cin >> test; while(test--){ solve(); } }

Compilation message (stderr)

bestplace.cpp:59:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   59 | 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...