fork download
  1. #include<iostream>
  2. #include<set>
  3. #include<stdio.h>
  4.  
  5. using namespace std; multiset<int> myset; int main() {
  6.  
  7. int test;
  8. cin>>test;
  9. int e=test;
  10. while(test)
  11. {
  12. test=test-1;
  13. //test++;
  14. char input;
  15. int value;
  16. //scanf("%c",&input);
  17. cin>>input;
  18.  
  19. //scanf("%d",&value);
  20. cin>>value;
  21. if(input=='a')
  22. {
  23. //cout<<"byeeeeeeeee\n"<<test<<"lsfhvfduhvl";
  24. myset.insert(value);
  25. int a=myset.size();
  26. if(a%2!=0) //odd case
  27. {
  28. multiset<int> :: const_iterator it=myset.begin();
  29. for(int i=0;i<(a/2);i++)
  30. {
  31. it++;
  32. }
  33. printf("%d\n",*it);
  34. //cout<<(*it)<<"\n";
  35. }
  36. else
  37. {
  38. int b,c;
  39. multiset<int> :: const_iterator it=myset.begin();
  40. for(int i=0;i<(a/2);i++)
  41. {
  42. it++;
  43. }
  44. b=(*it);
  45. it--;
  46. c=(*it);
  47. double x= 1.0*(b+c)/2;
  48. printf("%.10g\n",x);
  49. //cout<<setprecision(9)<<x<<"\n";
  50.  
  51. }
  52. }
  53. else if(input=='r')
  54. {
  55. //cout<<"hiiiiiiiiiiiii\n"<<test<<"lufhvfdhsv";
  56.  
  57. if(myset.find(value)!=myset.end())
  58. {
  59. cout<<"hiiiiiiiiiiiii";
  60. myset.erase(myset.find(value));
  61.  
  62. if(!myset.empty())
  63. {
  64. int a=myset.size();
  65.  
  66. if(a%2!=0) //odd case
  67. {
  68. multiset< int > :: const_iterator it=myset.begin();
  69. for(int i=0;i<(a/2);i++)
  70. {
  71. it++;
  72. }
  73. printf("%d\n",*it);
  74. //cout<<(*it)<<"\n";
  75. }
  76. else
  77. {
  78. int b,c;
  79. multiset< int > :: const_iterator it=myset.begin();
  80. for(int i=0;i<(a/2);i++)
  81. {
  82. it++;
  83. }
  84. b=(*it);
  85. it--;
  86. c=(*it);
  87. //cout<<1.*(b+c)/2<<"\n";
  88. double x= 1.0*(b+c)/2;
  89. printf("%.10g\n",x);
  90. //cout<<setprecision(9)<<x<<"\n";
  91.  
  92. }
  93. }
  94. else
  95. cout<<"Wrong!\n";
  96.  
  97. }
  98. else
  99. {
  100. cout<<"Wrong!\n";
  101. }
  102.  
  103. }
  104.  
  105. }
  106. return 0;
  107.  
  108. }
Success #stdin #stdout 0.01s 2820KB
stdin
 7
r 1
a 1
a 2
a 1
r 1
r 2
r 1
stdout
Wrong!
1
1.5
1
hiiiiiiiiiiiii1.5
hiiiiiiiiiiiii1
hiiiiiiiiiiiiiWrong!