tonfain

cowAteHW_tonfai

Dec 21st, 2022
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5. ifstream fin("homework.in");
  6. ofstream fout("homework.out");
  7.  
  8. int N; fin >> N;
  9. queue<int> scores;
  10. vector<int> scoresV(N);
  11. queue<int> mins;
  12. int sum = 0;
  13. for(int i = 0; i<N; i++){
  14. fin >> scoresV[i];
  15. sum += scoresV[i];
  16.  
  17. scores.push(scoresV[i]);
  18. }
  19. vector<int> sortedV = scoresV;
  20. sort(sortedV.begin(), sortedV.end());
  21. for(int i = 0; i<N; i++){
  22. mins.push(sortedV[i]);
  23. }
  24. //cout << "sums: " << sum << endl;
  25.  
  26. double mx = 0;
  27. int ans = 0;
  28. for(int i = 0; i<N-1; i++){
  29. int num = N-i-1;
  30.  
  31. //cout << "sum: " << sum << endl;
  32. //cout << "scores.front(): " << scores.front() << endl;
  33. //if(i != 0){
  34. //sum -= scores.front();
  35. //}
  36.  
  37.  
  38. int finalsum = sum - mins.front();
  39.  
  40.  
  41. //cout << "mins.front(): " << mins.front() << endl;
  42. //cout << "final sum: " << finalsum << endl;
  43.  
  44. //if(scores.front() == mins.front()){
  45. //mins.pop();
  46. //}
  47. //scores.pop();
  48. double avg = (double)finalsum/(double)num;
  49. //cout << "avg: " << avg << endl;
  50. if(avg > mx){
  51. if (mx != 0){
  52. ans = i;
  53. }
  54. //cout << "at i: " << i << ", avg: " << avg << " is bigger than mx: " << mx << ", ans: " << ans << endl;
  55. mx = avg;
  56.  
  57. }
  58. if(scores.front() == mins.front()){
  59. mins.pop();
  60. }
  61. sum -= scores.front();
  62. scores.pop();
  63. //if(i != 0){
  64. //sum -= scores.front();
  65. //}
  66. //mx = max(mx, avg);
  67. }
  68. fout << ans << endl;
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment