foo.cc: In function 'int main()':
foo.cc:13:2: error: 'sort' was not declared in this scope
  sort(a,a+n);
  ^~~~
foo.cc:13:2: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from foo.cc:2:
/usr/include/c++/7/bits/stl_algo.h:4856:5: note:   'std::sort'
     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
     ^~~~
foo.cc:6:30: warning: unused variable 'flag' [-Wunused-variable]
  int i,n,w,a[300005],j,num=0,flag=0;
                              ^~~~
foo.cc:7:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&w);
  ~~~~~^~~~~~~~~
foo.cc:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
foo.cc:11:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);//a[i]里是价格
   ~~~~~^~~~~~~~~~~~