Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #define pii pair <int,int>
- #define vec vector
- using namespace std;
- using ll = long long;
- using ld = long double;
- using db = double;
- void cv(vector <int> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvl(vector <ll> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvv(vector <vector <int> > &v){
- for (auto x: v) cv(x);
- cout<<"\n";
- }
- void cvb(vector <bool> v){
- for (bool x: v) cout<<x<<' ';
- cout<<"\n";
- }
- bool cmp(pii a, pii b){
- return a.second < b.second || a.second == b.second && a.first > b.first;
- }
- int main()
- {
- /*ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);*/
- int n,k;
- cin>>n>>k;
- vector <int> x(n); for (int &i: x) cin>>i;
- sort(x.begin(), x.end());
- vector <int> a(n,0), b(n,0);
- for (int i = 1; i < n; ++i){
- a[i] = a[i-1] + abs(x[i] - x[i-1]);
- }
- for (int i = n - 2; i >= 0; --i){
- b[i] = b[i + 1] + abs(x[i] - x[i+1]);
- }
- vector <int> c(n);
- for (int i = 0; i < n;++i){
- c[i] = a[i] + b[i];
- }
- vector <int> res;
- for (int i = )
- vector <pii> d(n);
- for (int i = 0; i < n;++i){
- d[i] = {x[i], c[i]};
- }
- cout<<"x\n";
- cv(x);
- cout<<"a\n";
- cv(a);
- cout<<"b\n";
- cv(b);
- cout<<"c\n";
- cv(c);
- sort(d.begin(), d.end(), cmp);
- cout<<d[0].first<<' '<<d[0].second;
- }
Add Comment
Please, Sign In to add comment