Submission #1103961

#TimeUsernameProblemLanguageResultExecution timeMemory
1103961vjudge1Global Warming (CEOI18_glo)C++17
100 / 100
44 ms4340 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 1; const int INF = 2e9; int arr[N] , ans; int l[N] , r[N]; vector<int> dp; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,x; cin >> n >> x; for (int i=1;i<=n;i++) cin >> arr[i]; for (int i=1;i<=n;i++) { int idx = lower_bound(dp.begin(), dp.end(), arr[i]) - dp.begin(); l[i] = idx + 1; if (idx==dp.size()) dp.push_back(arr[i]); dp[idx] = arr[i]; } dp.clear(); for(int i=n;i>=1;i--) { int idx = lower_bound(dp.begin(), dp.end(), -arr[i] + x) - dp.begin(); r[i] = idx + 1; idx = lower_bound(dp.begin(), dp.end(), -arr[i]) - dp.begin(); if (idx==dp.size()) dp.push_back(-arr[i]); dp[idx] = -arr[i]; } int ans = 0; for (int i=1;i<=n;i++) ans = max(ans, l[i] + r[i] - 1); cout << ans; return 0; }

Compilation message (stderr)

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