Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. // EZBECE.cpp: определяет точку входа для консольного приложения.
  2. //
  3. /*#include "stdafx.h"
  4. #include <iostream>
  5. #include <string>
  6. #include <vector>
  7. #include <algorithm>
  8.  
  9.  
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14. int students, transfer_time, time_of_each_student[24];
  15. long ideal_time;
  16. cin>>students>>ideal_time>>transfer_time;
  17. if((students%4)==0)
  18. {
  19. for(int i=0;i<students;i++)
  20. cin>>time_of_each_student[i];
  21.  
  22. }
  23. else
  24. cout<<"error";
  25.  
  26. return 0;
  27. }*/
  28. #include "stdafx.h"
  29. #include <iostream>
  30. #include <string>
  31. #include <vector>
  32. #include <algorithm>
  33.  
  34.  
  35. using namespace std;
  36.  
  37. int main()
  38. {
  39. long ideal_time;
  40. int students,time;
  41. int transfer_time;
  42. cin>> students>>ideal_time>>transfer_time;
  43. if((students%4)==0)
  44. {
  45. vector<int> results;
  46. for(int i=0;i<students;i++)
  47. {
  48. int n;
  49. cin>>n;
  50. results.push_back(n);
  51. }
  52. sort(results.begin(),results.end());
  53. for(int i=0;i<students;i++)
  54. {
  55. cout<<results[i];
  56. }
  57. int i=0,j=students-1,k=0,time=0;
  58. do
  59. {
  60. time+=results[i]+results[i+1];
  61. time+=results[j]+results[j-1];
  62. time+=3*transfer_time;
  63. if(time<=ideal_time)
  64. {
  65. i+=2;
  66. j-=2;
  67. ++k;
  68. }
  69.  
  70. else
  71. j-=4;
  72. cout<<k;
  73. }while(!(i+2==j-1));
  74. printf("%d",k*4);
  75. }
  76. else
  77. cout<<"error";
  78. system("pause");
  79. return 0;
  80. }
  81. // EZBECE.cpp: определяет точку входа для консольного приложения.
  82. //
  83. /*#include "stdafx.h"
  84. #include <iostream>
  85. #include <string>
  86. #include <vector>
  87. #include <algorithm>
  88.  
  89.  
  90. using namespace std;
  91.  
  92. int main()
  93. {
  94. int students, transfer_time, time_of_each_student[24];
  95. long ideal_time;
  96. cin>>students>>ideal_time>>transfer_time;
  97. if((students%4)==0)
  98. {
  99. for(int i=0;i<students;i++)
  100. cin>>time_of_each_student[i];
  101.  
  102. }
  103. else
  104. cout<<"error";
  105.  
  106. return 0;
  107. }*/
  108. #include "stdafx.h"
  109. #include <iostream>
  110. #include <string>
  111. #include <vector>
  112. #include <algorithm>
  113.  
  114.  
  115. using namespace std;
  116.  
  117. int main()
  118. {
  119. long ideal_time;
  120. int students,time;
  121. int transfer_time;
  122. cin>> students>>ideal_time>>transfer_time;
  123. if((students%4)==0)
  124. {
  125. vector<int> results;
  126. for(int i=0;i<students;i++)
  127. {
  128. int n;
  129. cin>>n;
  130. results.push_back(n);
  131. }
  132. sort(results.begin(),results.end());
  133. for(int i=0;i<students;i++)
  134. {
  135. cout<<results[i];
  136. }
  137. int i=0,j=students-1,k=0,time=0;
  138. do
  139. {
  140. time+=results[i]+results[i+1];
  141. time+=results[j]+results[j-1];
  142. time+=3*transfer_time;
  143. if(time<=ideal_time)
  144. {
  145. i+=2;
  146. j-=2;
  147. ++k;
  148. }
  149.  
  150. else
  151. j-=4;
  152. cout<<k;
  153. }while(!(i+2==j-1));
  154. printf("%d",k*4);
  155. }
  156. else
  157. cout<<"error";
  158. system("pause");
  159. return 0;
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement