Submission #754338

#TimeUsernameProblemLanguageResultExecution timeMemory
754338sangerafGlobal Warming (CEOI18_glo)C++17
17 / 100
96 ms4292 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n, x; cin >> n >> x; vector<long long> v(n+1, 0); for(int i=1; i<=n; i++){ cin >> v[i]; } vector<long long> lj; lj.push_back(v[1]); vector<int> elol(n+1, 0); elol[1]=1; for(int i=2; i<=n; i++){ int j = lower_bound(lj.begin(), lj.end(), v[i]) - lj.begin(); elol[i]=elol[i-1]; if(j == lj.size()){ lj.push_back(0); elol[i]++; } lj[j]=v[i]; } lj.clear(); lj.push_back(-v[n]); vector<int> hatul(n+2, 0); hatul[n]=1; for(int i=n-1; i>0; i--){ int j = lower_bound(lj.begin(), lj.end(), -v[i]) - lj.begin(); hatul[i]=hatul[i+1]; if(j == lj.size()){ lj.push_back(0); hatul[i]++; } lj[j]=-v[i]; } int maxi=0; for(int i=0; i<n; i++){ maxi=max(maxi, elol[i]+hatul[i+1]); } cout << maxi << endl; return 0; }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:18:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         if(j == lj.size()){
      |            ~~^~~~~~~~~~~~
glo.cpp:32:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         if(j == lj.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...