fork download
  1. /******************************************************************************
  2.  
  3. Welcome to GDB Online.
  4. GDB online is an online compiler and debugger tool for C/C++.
  5. Code, Compile, Run and Debug online from anywhere in world.
  6.  
  7. *******************************************************************************/
  8. #include <bits/stdc++.h>
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13. //1 --> azul, 2 --> verde, 3 --> negro
  14. set<int> azul;
  15. set<int> verde;
  16. set<int> negro;
  17.  
  18. int t;
  19. cin >> t;
  20. vector<int> b(t);
  21. int a;
  22.  
  23. for (int i = 0; i < t; ++i) cin >> b[i];
  24. for (int i = 0; i < t; ++i) {
  25. cin >> a;
  26. if (a == 1) azul.insert(b[i]);
  27. else if (a == 2) verde.insert(b[i]);
  28. else negro.insert(b[i]);
  29. }
  30. for (int i = 0; i < t; ++i) {
  31. cin >> a;
  32. if (a == 1) azul.insert(b[i]);
  33. else if (a == 2) verde.insert(b[i]);
  34. else negro.insert(b[i]);
  35. }
  36.  
  37.  
  38. cin >> t;
  39. int n;
  40. for (int i = 0; i < t; ++i) {
  41. cin >> a;
  42.  
  43. if (a == 1) {
  44. if (azul.empty()) cout << -1 << ' ';
  45. else {
  46. cout << *azul.cbegin() << ' ';
  47. azul.erase(*azul.cbegin());
  48.  
  49. }
  50. }
  51. else if (a == 2) {
  52. if (verde.empty()) cout << -1 << ' ';
  53. else {
  54. cout << *verde.cbegin() << ' ';
  55. verde.erase(*verde.cbegin());
  56.  
  57. }
  58. }
  59. else {
  60. if (negro.empty()) cout << -1 << ' ';
  61. else {
  62. cout << *negro.cbegin() << ' ';
  63. negro.erase(*negro.cbegin());
  64. }
  65. }
  66. }
  67.  
  68.  
  69.  
  70. return 0;
  71. }
Success #stdin #stdout 0s 5320KB
stdin
45
stdout
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1