fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int n, m, l1, r1, l2, r2, l3, r3;
  6. int cnt1, cnt2, cnt3;
  7. int score1, score2;
  8.  
  9. int main(){
  10. cin >> n >> m >> l1 >> r1 >> l2 >> r2;
  11. l3 = max(l1, l2);
  12. r3 = min(r1, r2);
  13. for(int i = 1; i <= n; ++i){
  14. int x;
  15. cin >> x;
  16. if(l1 <= x && x <= r1)
  17. ++cnt1;
  18. if(l2 <= x && x <= r2)
  19. ++cnt2;
  20. if(l3 <= x && x <= r3)
  21. ++cnt3;
  22. }
  23. cnt1 -= cnt3;
  24. cnt2 -= cnt1;
  25. score1 = min(cnt1 + (cnt3 / 2) + (cnt3 % 2), m / 2 + m % 2);
  26. score2 = min(cnt2 + (cnt3 / 2), m / 2);
  27. if(score1 > score2){
  28. cout << "Petya";
  29. }
  30. else if(score1 == score2){
  31. cout << "Draw";
  32. }
  33. else {
  34. cout << "Vasya";
  35. }
  36. return 0;
  37. }
Success #stdin #stdout 0s 3300KB
stdin
4 3
1 2
2 4
1 2 3 4
stdout
Petya