Submission #1103955

#TimeUsernameProblemLanguageResultExecution timeMemory
1103955vjudge1Global Warming (CEOI18_glo)C++17
100 / 100
41 ms4308 KiB
#include <iostream> #include<vector> #include<algorithm> using namespace std; int arr[200005]; int len[200005]; int mx,idx; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n,x; cin >> n >> x; for(int i=0;i<n;++i) cin >> arr[i]; vector<int> dp; for(int i=0;i<n;++i){ idx=lower_bound(dp.begin(),dp.end(),arr[i])-dp.begin(); if(idx==dp.size()) dp.push_back(arr[i]); else dp[idx]=arr[i]; len[i] = idx+1; mx=max(mx,len[i]); } dp.clear(); for(int i=n-1;i>0;--i){ idx=lower_bound(dp.begin(),dp.end(),-arr[i]+x)-dp.begin(); mx=max(mx,len[i]+idx); idx=lower_bound(dp.begin(),dp.end(),-arr[i])-dp.begin(); if(idx==dp.size()) dp.push_back(-arr[i]); else dp[idx]=-arr[i]; } cout << mx << endl; }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |         if(idx==dp.size()) dp.push_back(arr[i]);
      |            ~~~^~~~~~~~~~~
glo.cpp:25:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if(idx==dp.size()) dp.push_back(-arr[i]);
      |            ~~~^~~~~~~~~~~
#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...