Submission #774621

#TimeUsernameProblemLanguageResultExecution timeMemory
774621vgoofficialGlobal Warming (CEOI18_glo)C++14
22 / 100
41 ms6200 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; vector<int> magic2; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n,x; cin >> n >> x; int temps[n]; for(int i = 0; i < n; i++) cin >> temps[i]; int longestIncreasing[n+1], largestNumber[n+1], longestIncreasing2[n+1]; vector<int> magic; longestIncreasing[0]=0; largestNumber[0]=1<<31; longestIncreasing2[n]=0; magic.push_back(temps[0]); longestIncreasing[1]=1; largestNumber[1]=-(temps[0]-x); for(int i = 1; i < n; i++) { int lb = lower_bound(begin(magic), end(magic), temps[i])-begin(magic); if(lb==magic.size()) { magic.push_back(temps[i]); } else { magic[lb]=temps[i]; } longestIncreasing[i+1]=magic.size(); largestNumber[i+1]=-(magic.back()-x); } for(int i = 0; i < n; i++) { temps[i]*=-1; } vector<int> magic2; magic2.push_back(temps[n-1]); if(temps[n-1]<largestNumber[n-1]) { longestIncreasing2[n-1]=1; } else { longestIncreasing2[n-1]=0; } for(int i = n-2; i >= 0; i--) { int lb = lower_bound(begin(magic2), end(magic2), temps[i])-begin(magic2); if(lb==magic2.size()) { magic2.push_back(temps[i]); } else { magic2[lb]=temps[i]; } int lbb = lower_bound(begin(magic2), end(magic2), largestNumber[i])-begin(magic2); if(lbb==magic2.size()) { longestIncreasing2[i]=magic2.size(); } else if(magic2[lbb]==largestNumber[i]) { longestIncreasing2[i]=lbb; } else { longestIncreasing2[i]=lbb+1; } } int max = 0; for(int i = 0; i <= n; i++) { max=std::max(max, longestIncreasing[i]+longestIncreasing2[i]); } cout << max << endl; }

Compilation message (stderr)

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