제출 #246340

#제출 시각아이디문제언어결과실행 시간메모리
246340SortingGlobal Warming (CEOI18_glo)C++14
55 / 100
2070 ms3052 KiB
#include <bits/stdc++.h> using namespace std; const int k_N = 2e5 + 3; const int k_Inf = 1e9 + 3; int n, x; int t[k_N]; int ans[k_N]; int get_lis(){ vector<int> dp; dp.push_back({-k_Inf}); for(int i = 0; i < n; ++i){ auto it = lower_bound(dp.begin(), dp.end(), t[i]); if(it == dp.end()) dp.push_back(t[i]); else dp[it - dp.begin()] = t[i]; ans[i] += dp.size() - 1; } return dp.size() - 1; } void get_lds(){ vector<int> dp; dp.push_back({k_Inf}); for(int i = n - 1; i >= 0; --i){ int l = 0, r = dp.size(); while(l != r){ int mid = (l + r) >> 1; if(t[i] >= dp[mid]) r = mid; else l = mid + 1; } if(l == dp.size()) dp.push_back(t[i]); else dp[l] = t[i]; //cout << dp.size() << "\n"; ans[i - 1] += dp.size() - 1; } } int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> x; for(int i = 0; i < n; ++i) cin >> t[i]; if(x == k_Inf - 3){ int answer = 0; get_lds(); get_lis(); for(int i = 0; i < n; ++i) answer = max(ans[i], answer); cout << answer << "\n"; } else{ int answer = 0; for(int i = 0; i < n; ++i){ t[i] -= x; answer = max(get_lis(), answer); if(x == 0) break; } cout << answer << "\n"; } }

컴파일 시 표준 에러 (stderr) 메시지

glo.cpp: In function 'void get_lds()':
glo.cpp:42:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(l == 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...