Submission #784380

#TimeUsernameProblemLanguageResultExecution timeMemory
784380LyricallyHoliday (IOI14_holiday)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define pii pair<int,int> #define pb push_back #define rep(i,n) for(int i=0;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) int read(){int x;scanf("%d",&x);return x;} void print(int x){printf("%d\n",x);} void file(string s) { freopen((s+".in").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } const int mod=998244353; long long a[100005]; long long n,s,d; long long calc(int x) { multiset<int> st; for(int i=x;i<s;i++){st.insert(a[i]);} long long res=0; for(int i=s;i<=n;i++) { int lst=i-x+min(i-s,s-x); if(lst>d){continue;} st.insert(a[i]); lst=d-lst; vector<int> v; long long cur=0; for(int j=1;j<=lst;j++) { if(st.empty()){break;} cur+=*(--st.end()); v.pb(*(--st.end())); st.erase(--st.end()); } res=max(res,cur); //cout<<i<<" "<<lst<<" "<<cur<<endl; for(auto x:v){st.insert(x);} //for(auto v:st){cout<<v<<" ";} //cout<<endl; } return res; } long long findMaxAttraction(int N,int S,int D,int attr[]) { n=N,s=S+1,d=D; rep(i,n){a[i+1]=attr[i];} //往左去到的最远地方 long long res=0; for(int i=1;i<=min(s,20);i++) { long long x=calc(i); res=max(res,x); } for(int i=max(s-20,1);i<=s;i++) { long long x=calc(i); res=max(res,x); } reverse(a+1,a+n+1); s=n-s+1; if(s!=1) { for(int i=1;i<=min(s,20);i++) { long long x=calc(i); res=max(res,x); } for(int i=max(s-20,1);i<=s;i++) { long long x=calc(i); res=max(res,x); } } return res; }

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:51:25: error: no matching function for call to 'min(long long int&, int)'
   51 |  for(int i=1;i<=min(s,20);i++)
      |                         ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from holiday.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
holiday.cpp:51:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   51 |  for(int i=1;i<=min(s,20);i++)
      |                         ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from holiday.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
holiday.cpp:51:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   51 |  for(int i=1;i<=min(s,20);i++)
      |                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from holiday.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
holiday.cpp:51:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   51 |  for(int i=1;i<=min(s,20);i++)
      |                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from holiday.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
holiday.cpp:51:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   51 |  for(int i=1;i<=min(s,20);i++)
      |                         ^
holiday.cpp:56:22: error: no matching function for call to 'max(long long int, int)'
   56 |  for(int i=max(s-20,1);i<=s;i++)
      |                      ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from holiday.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
holiday.cpp:56:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   56 |  for(int i=max(s-20,1);i<=s;i++)
      |                      ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from holiday.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
holiday.cpp:56:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   56 |  for(int i=max(s-20,1);i<=s;i++)
      |                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from holiday.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
holiday.cpp:56:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   56 |  for(int i=max(s-20,1);i<=s;i++)
      |                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from holiday.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
holiday.cpp:56:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   56 |  for(int i=max(s-20,1);i<=s;i++)
      |                      ^
holiday.cpp:65:26: error: no matching function for call to 'min(long long int&, int)'
   65 |   for(int i=1;i<=min(s,20);i++)
      |                          ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from holiday.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
holiday.cpp:65:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   65 |   for(int i=1;i<=min(s,20);i++)
      |                          ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from holiday.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
holiday.cpp:65:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   65 |   for(int i=1;i<=min(s,20);i++)
      |                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from holiday.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
holiday.cpp:65:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   65 |   for(int i=1;i<=min(s,20);i++)
      |                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from holiday.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
holiday.cpp:65:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   65 |   for(int i=1;i<=min(s,20);i++)
      |                          ^
holiday.cpp:70:23: error: no matching function for call to 'max(long long int, int)'
   70 |   for(int i=max(s-20,1);i<=s;i++)
      |                       ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from holiday.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
holiday.cpp:70:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   70 |   for(int i=max(s-20,1);i<=s;i++)
      |                       ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from holiday.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
holiday.cpp:70:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   70 |   for(int i=max(s-20,1);i<=s;i++)
      |                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from holiday.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
holiday.cpp:70:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   70 |   for(int i=max(s-20,1);i<=s;i++)
      |                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from holiday.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
holiday.cpp:70:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   70 |   for(int i=max(s-20,1);i<=s;i++)
      |                       ^
holiday.cpp: In function 'int read()':
holiday.cpp:7:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 | int read(){int x;scanf("%d",&x);return x;}
      |                  ~~~~~^~~~~~~~~
holiday.cpp: In function 'void file(std::string)':
holiday.cpp:11:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  freopen((s+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
holiday.cpp:12:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  freopen((s+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~