Language: C++


typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    ivec p(n);
    for (size_t i = 0; i < n; i++) cin >> p[i];
    double av=0;
    for (size_t i = 0; i < k; i++)
    {
        av+=(double)(p[i]+1)/2;
    }
    double ans = av;
    for (size_t i = k; i < n; i++)
    {   
        av-=(double)(p[i-k]+1)/2;
        av+=(double)(p[i]+1)/2;
        ans = fmax(ans, av);
    }
    
    cout << setprecision(10) << ans << endl;

}


Compiler output:
a.cc:2:9: error: 'vector' does not name a type
    2 | typedef vector<bool> bvec;
      |         ^~~~~~
a.cc:3:9: error: 'vector' does not name a type
    3 | typedef vector<int> ivec;
      |         ^~~~~~
a.cc:4:9: error: 'vector' does not name a type
    4 | typedef vector<long long> lvec;
      |         ^~~~~~
a.cc:5:9: error: 'vector' does not name a type
    5 | typedef vector<double> dvec;
      |         ^~~~~~
a.cc:6:9: error: 'vector' does not name a type
    6 | typedef vector<pa> pvec;
      |         ^~~~~~
a.cc:8:9: error: 'vector' does not name a type
    8 | typedef vector< vector<bool> > bmat;
      |         ^~~~~~
a.cc:9:9: error: 'vector' does not name a type
    9 | typedef vector< vector<int> > imat;
      |         ^~~~~~
a.cc:10:9: error: 'vector' does not name a type
   10 | typedef vector<string> svec;
      |         ^~~~~~
a.cc:11:9: error: 'vector' does not name a type
   11 | typedef vector< vector<string> > smat;
      |         ^~~~~~
a.cc: In function 'int main()':
a.cc:14:5: error: 'cin' was not declared in this scope
   14 |     cin.tie(0);
      |     ^~~
a.cc:15:5: error: 'ios' has not been declared
   15 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:18:5: error: 'ivec' was not declared in this scope
   18 |     ivec p(n);
      |     ^~~~
a.cc:19:10: error: 'size_t' was not declared in this scope
   19 |     for (size_t i = 0; i < n; i++) cin >> p[i];
      |          ^~~~~~
a.cc:1:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
  +++ |+#include <cstddef>
    1 | 
a.cc:19:24: error: 'i' was not declared in this scope
   19 |     for (size_t i = 0; i < n; i++) cin >> p[i];
      |                        ^
a.cc:19:43: error: 'p' was not declared in this scope
   19 |     for (size_t i = 0; i < n; i++) cin >> p[i];
      |                                           ^
a.cc:21:10: error: 'size_t' was not declared in this scope
   21 |     for (size_t i = 0; i < k; i++)
      |          ^~~~~~
a.cc:21:10: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
a.cc:21:24: error: 'i' was not declared in this scope
   21 |     for (size_t i = 0; i < k; i++)
      |                        ^
a.cc:23:22: error: 'p' was not declared in this scope
   23 |         av+=(double)(p[i]+1)/2;
      |                      ^
a.cc:26:10: error: 'size_t' was not declared in this scope
   26 |     for (size_t i = k; i < n; i++)
      |          ^~~~~~
a.cc:26:10: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
a.cc:26:24: error: 'i' was not declared in this scope
   26 |     for (size_t i = k; i < n; i++)
      |                        ^
a.cc:28:22: error: 'p' was not declared in this scope
   28 |         av-=(double)(p[i-k]+1)/2;
      |                      ^
a.cc:30:15: error: 'fmax' was not declared in this scope
   30 |         ans = fmax(ans, av);
      |               ^~~~
a.cc:33:5: error: 'cout' was not declared in this scope
   33 |     cout << setprecision(10) << ans << endl;
      |     ^~~~
a.cc:33:13: error: 'setprecision' was not declared in this scope
   33 |     cout << setprecision(10) << ans << endl;
      |             ^~~~~~~~~~~~
a.cc:33:40: error: 'endl' was not declared in this scope
   33 |     cout << setprecision(10) << ans << endl;
      |                                        ^~~~