Submission #503873

#TimeUsernameProblemLanguageResultExecution timeMemory
503873krit3379Global Warming (CEOI18_glo)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define N 300005 int a[N],b[N],c[N],dp1[N]; vector<int> s1,s2; int main(){ long long n,d,i,ans=0; scanf("%d %d",&n,&d); for(i=1;i<=n;i++)scanf("%d",&a[i]),b[i]=-a[i]; for(i=1;i<=n;i++){ auto x=lower_bound(s1.begin(),s1.end(),a[i]); if(x==s1.end())s1.push_back(a[i]); else *x=a[i]; dp1[i]=s1.size(); c[i]=s1.back(); } for(i=n;i>0;i--){ int it=lower_bound(s2.begin(),s2.end(),-c[i]+d)-(s2.begin()); ans=max(ans,dp1[i]+it); auto x=lower_bound(s2.begin(),s2.end(),b[i]); if(x==s2.end())s2.push_back(b[i]); else *x=b[i]; //printf("i=%d dp=%d it=%d\n",i,dp1[i-1],it); } printf("%d\n",ans); return 0; }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:10:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   10 |     scanf("%d %d",&n,&d);
      |            ~^     ~~
      |             |     |
      |             int*  long long int*
      |            %lld
glo.cpp:10:16: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   10 |     scanf("%d %d",&n,&d);
      |               ~^     ~~
      |                |     |
      |                int*  long long int*
      |               %lld
glo.cpp:21:30: error: no matching function for call to 'max(long long int&, int)'
   21 |         ans=max(ans,dp1[i]+it);
      |                              ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from glo.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:
glo.cpp:21:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   21 |         ans=max(ans,dp1[i]+it);
      |                              ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from glo.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:
glo.cpp:21:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   21 |         ans=max(ans,dp1[i]+it);
      |                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from glo.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:
glo.cpp:21:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   21 |         ans=max(ans,dp1[i]+it);
      |                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from glo.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:
glo.cpp:21:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   21 |         ans=max(ans,dp1[i]+it);
      |                              ^
glo.cpp:27:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   27 |     printf("%d\n",ans);
      |             ~^    ~~~
      |              |    |
      |              int  long long int
      |             %lld
glo.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %d",&n,&d);
      |     ~~~~~^~~~~~~~~~~~~~~
glo.cpp:11:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for(i=1;i<=n;i++)scanf("%d",&a[i]),b[i]=-a[i];
      |                      ~~~~~^~~~~~~~~~~~