Submission #916348

#TimeUsernameProblemLanguageResultExecution timeMemory
916348KactusJackGlobal Warming (CEOI18_glo)C++14
0 / 100
36 ms2652 KiB
#include<bits/stdc++.h> #define ll long long #define F first #define S second using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, x; cin >> n >> x; vector<int> a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } vector<int> prefix(n), suffix(n), dp; for(int i = 0; i < n; i++){ a[i] -= x; int j = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin(); if(j == dp.size()){ dp.push_back(a[i]); } else{ dp[j] = a[i]; } prefix[i] = j+1; } dp.clear(); for(int i = n-1; i >= 0; i--){ int j = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin(); if(j == dp.size()){ dp.push_back(a[i]); } else{ dp[j] = a[i]; } suffix[i] = j+1; } int ans = 0; for(int i = 0; i < n; i++){ ans = max(ans, prefix[i] + suffix[i] - 1); } cout << ans << "\n"; return 0; }

Compilation message (stderr)

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