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";
- }
- void cvs(vector <string> v){
- for (auto a: v){
- cout<<a<<"\n";
- }
- }
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- int n,k;
- cin>>n>>k;
- vector <int> a(n);
- for (int &x: a) cin>>x;
- /*4 1
- 1 1 3 4*/
- sort(a.begin(), a.end());
- vector <int> odd(n), even(n);
- int cnt = n-1;
- for (int i = 0; i < n;++i){
- if (cnt - 1 >= 0)odd[i] = a[cnt] - a[cnt-1];
- else odd[i] = a[0];
- cout<<"cnt = "<<cnt<<"\n";
- cnt--;
- }
- for (int i = 0; i < n;++i){
- even[i] = a[i] - a[0];
- }
- cout<<"odd\n";
- cv(odd);
- cout<<"even\n";
- cv(even);
- if (k % 2 == 1){
- for (int i = 0; i < n - k/2; ++i){
- for (int j = 0; j < odd[i];++j){
- cout<<i+1<<' ';
- }
- }
- }
- else{
- for (int i = k / 2 - 1; i < n; ++i){
- cout<<even[i]<<' ';
- }
- }
- }
Add Comment
Please, Sign In to add comment