Submission #1048591

#TimeUsernameProblemLanguageResultExecution timeMemory
1048591MrAndriaGlobal Warming (CEOI18_glo)C++14
100 / 100
65 ms4304 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back //#define int long long int p[200005]; int a[200005],mx,n,k,x; int main(){ cin>>n>>x; for(int i=1;i<=n;i++){ cin>>a[i]; } vector <int> v; for(int i=1;i<=n;i++){ k=lower_bound(v.begin(),v.end(),a[i])-v.begin(); if(k==v.size()){ v.pb(a[i]); }else{ v[k]=a[i]; } p[i]=k+1; } v.clear(); mx=max(mx,p[n]); for(int i=n;i>=1;i--){ k=lower_bound(v.begin(),v.end(),x-a[i])-v.begin(); mx=max(mx,p[i]+k); k=lower_bound(v.begin(),v.end(),-a[i])-v.begin(); if(k==v.size()){ v.pb(-a[i]); }else{ v[k]=-a[i]; } } cout<<mx<<endl; }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:20:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         if(k==v.size()){
      |            ~^~~~~~~~~~
glo.cpp:35:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         if(k==v.size()){
      |            ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...