Submission #754328

#TimeUsernameProblemLanguageResultExecution timeMemory
754328sangerafGlobal Warming (CEOI18_glo)C++17
0 / 100
99 ms4512 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n, x; cin >> n >> x; vector<int> v(n+1, 0); for(int i=1; i<=n; i++){ cin >> v[i]; } vector<int> lj; lj.push_back(v[1]); vector<int> elol(n+1, 0); elol[1]=1; for(int i=2; i<=n; i++){ int j = upper_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-1]); vector<int> hatul(n+2, 0); hatul[n]=1; for(int i=n-1; i>0; i--){ int j = upper_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<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<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...