Submission #1104162

#TimeUsernameProblemLanguageResultExecution timeMemory
1104162vjudge1Global Warming (CEOI18_glo)C++17
0 / 100
38 ms2004 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 3; int ar[N]; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, x; cin >> n >> x; for(int i=1; i<=n; ++i) cin >> ar[i]; int res = 1; int dp[n+1]; dp[0] = 0; vector<int> lis; for(int i=1; i<=n; ++i) { auto t = lower_bound(lis.begin(), lis.end(), ar[i]); if(t == lis.end()) lis.emplace_back(ar[i]); else *t = ar[i]; dp[i] = lis.size(); } res = lis.size(); lis.clear(); for(int i=n; i>=1; --i) { int x = lower_bound(lis.begin(), lis.end(), -ar[i] + x) - lis.begin(); res = max(res, dp[i-1] + x); auto t = lower_bound(lis.begin(), lis.end(), -ar[i]); if(t == lis.end()) lis.emplace_back(-ar[i]); else *t = -ar[i]; } cout << res << '\n'; return 0; }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:27:56: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |     int x = lower_bound(lis.begin(), lis.end(), -ar[i] + x) - lis.begin();
      |                                                 ~~~~~~~^~~
#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...