제출 #916346

#제출 시각아이디문제언어결과실행 시간메모리
916346KactusJackGlobal 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--){
        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];
        }
        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;
}

컴파일 시 표준 에러 (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:32:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         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...