Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define pb push_back
  4. #define mp make_pair
  5. #define fr first
  6. #define sc second
  7. #define in insert
  8.  
  9. using namespace std;
  10.  
  11. typedef long long ll;
  12.  
  13. int n, p;
  14. int bol[100010];
  15. vector <ll> a, b;
  16. ll c;
  17. map <ll, int> ans;
  18. vector <pair<int, int> > kok;
  19.  
  20. int main()
  21. {
  22. cin >> n >> p >> c;
  23. for (int i = 0; i < n; i++)
  24. {
  25. int q;
  26. cin >> q;
  27. ans[q] = i;
  28. a.pb(q);
  29. b.pb(q + c);
  30. kok.pb(mp(q, 0));
  31. }
  32. sort(a.rbegin(), a.rend());
  33. sort(b.rbegin(), b.rend());
  34. for (int i = 0; i < n; i++)
  35. {
  36. int pop = (int)(lower_bound(b.begin(), b.end(), a[i] + c) - b.begin());
  37. b[pop] = a[i];
  38. sort(b.rbegin(), b.rend());
  39. if (b[p - 1] <= a[i])
  40. bol[ans[a[i]]] = 2;
  41. else if (b[p - 1] <= a[i] + c)
  42. bol[ans[a[i]]] = 1;
  43. else
  44. bol[ans[a[i]]] = 0;
  45. pop = (int)(lower_bound(b.begin(), b.end(), a[i]) - b.begin());
  46. b[pop] = a[i] + c;
  47. sort(b.rbegin(), b.rend());
  48. }
  49. for (int i = 0; i < kok.size(); i++)
  50. kok[i].sc = bol[ans[kok[i].fr]];
  51. for (int i = 0; i < kok.size(); i++)
  52. if (kok[i].sc == 0)
  53. cout << "Fail\n";
  54. else if (kok[i].sc == 1)
  55. cout << "Short\n";
  56. else
  57. cout << "Pass\n";
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement