fork download
  1. #include<bits/stdc++.h>
  2. #include<unordered_map>
  3. #pragma GCC target ("avx2")
  4. #pragma GCC optimization ("O3")
  5. #pragma GCC optimization ("unroll-loops")
  6. #define endl '\n'
  7. #define Ceil(x,y) ((x+y-1)/y)
  8. #define sz(s) (int)s.size()
  9. #define RT(x) return cout<<x,0;
  10. #define mem(x,y) memset(x,y,sizeof(x))
  11. #define all(v) ((v).begin()), ((v).end())
  12. #define vi vector<int>
  13. #define pii pair<int,int>
  14. #define watch(x) cout<<(#x)<<" = "<<x<<endl
  15. #define forr(i, n) for (int i = 0; i < int(n); i++)
  16. int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
  17. int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
  18. const double PI = acos(-1), EPS = 1e-7;
  19. const int OO = 0x3f3f3f3f, N = 1e7 + 5, mod = 1e9 + 7;
  20. using namespace std;
  21. typedef long long ll;
  22. typedef unsigned long long ull;
  23. ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x%y); }
  24. ll lcm(ll x, ll y) { return ((x / gcd(x, y))*y); }
  25. void mansour()
  26. {
  27. std::ios_base::sync_with_stdio(0);
  28. cin.tie(NULL);
  29. cout.tie(NULL);
  30. }
  31. void file()
  32. {
  33. #ifndef ONLINE_JUDGE
  34. freopen("input.txt" , "r" , stdin) ;
  35. freopen("output.txt" , "w" , stdout) ;
  36. #endif
  37. }
  38. void ciel_floor(double x)
  39. {
  40. printf ( "ceil of 2.3 is %.1f\n", ceil(2.3) );//3
  41. printf ( "floor of 2.3 is %.1lf\n", floor (2.3) );//2
  42. }
  43. map<pair<int,int>,bool>mp;
  44. int main()
  45. {
  46. mansour();
  47. file();
  48. /*7llly ya gazmaaaaaa*/
  49. //298966RN
  50. int n,k,a[202];
  51. vector<pair<int,int>>v;
  52. cin>>n>>k;
  53. for(int i=0;i<=2*n;i++)
  54. {
  55. cin>>a[i];
  56. v.push_back(make_pair(-1*a[i],i));
  57. }
  58. sort(all(v));
  59. for(int i=0;i<=2*n;i++)
  60. mp[make_pair(v[i].first*-1,v[i].second)]=0;
  61. for(int i=0;i<=2*n;i++)
  62. {
  63. if(!k)
  64. break;
  65. if(!(a[v[i].second-1]==v[i].first*-1-1 || a[v[i].second+1]==v[i].first*-1-1))
  66. {
  67. mp[make_pair(v[i].first*-1,v[i].second)]=1;
  68. k--;
  69. }
  70.  
  71.  
  72. }
  73. for(int i=1;i<2*n;i++)
  74. {
  75. if(mp[make_pair(a[i],i)])
  76. {
  77. a[i]--;
  78. k--;
  79. }
  80. }
  81. for(int i=0;i<=2*n;i++)
  82. cout <<a[i]<<" ";
  83. cout <<"\n";
  84. }
Success #stdin #stdout 0s 4524KB
stdin
Standard input is empty
stdout
0