fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define pb push_back
  5. #define all(a) a.begin(), a.end()
  6. #define rep(i, x, n) for (int i = x; i <= n; ++i)
  7. #define inp(a) freopen(a".inp", "r", stdin), freopen(a".out", "w", stdout)
  8.  
  9.  
  10. int n, k;
  11. int main(){
  12. cin.tie(0) -> sync_with_stdio(0);
  13. inp("hopqua");
  14.  
  15. cin >>n >>k;
  16.  
  17. vector<int> a(n);
  18.  
  19. for (int &x: a) cin >>x;
  20.  
  21. sort(all(a));
  22. int cnt = 0, value = 0;
  23.  
  24. for (int x: a){
  25. rep(i, 0, n - 1){
  26. int c = 0, op = 0;
  27.  
  28. rep(j, i, n - 1){
  29. if (a[j] > x) break;
  30.  
  31. op += x - a[j];
  32.  
  33. if (op > k) break;
  34.  
  35. ++c;
  36. }
  37.  
  38. if (c > cnt){
  39. cnt = c; value = x;
  40. }
  41. }
  42. }
  43.  
  44. cout <<cnt <<' ' <<value;
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
Standard output is empty