제출 #668825

#제출 시각아이디문제언어결과실행 시간메모리
668825asdf1234codingGlobal Warming (CEOI18_glo)C++14
0 / 100
44 ms4656 KiB
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
using namespace std;

#define problemname "glo"
#define pii pair<int,int>
#define vi vector<int>
#define pb push_back
#define MOD (int)1e9+7
#define ll long long
#define ff first
#define ss second

bool ckmin(int& a, int b) {return a>b?a=b,true:false;}
bool ckmax(int& a, int b) {return a<b?a=b,true:false;}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // freopen (problemname ".in", "r", stdin); freopen(problemname ".out", "w", stdout);
    int n,x;cin>>n>>x;
    vi a(n); for(auto& x: a) cin>>x;
    vi left;
    vi dp;
    int ans = 0;
    for(auto lmao:a) {
        int pos = lower_bound(dp.begin(), dp.end(), lmao) - dp.begin();
        if(pos == dp.size()) {
            dp.pb(x);
        } else {
            dp[pos]=lmao;
        }
        left.pb(pos);
        ckmax(ans, left[left.size()-1]);
    }
    dp.clear();
    vi right;
    for(int i=n-1; i>=0; i--) {
        a[i]=-a[i];
        int pos = lower_bound(dp.begin(), dp.end(), a[i] + x) - dp.begin();
        int ins = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
        if(ins == dp.size()) {
            dp.pb(a[i]);
        } else {
            dp[ins]=a[i];
        }
        right.pb(dp.size());
        a[i]=-a[i];
        ckmax(ans, left[i]+pos);
    }
    cout<<ans+1<<endl;
    return 0;
}

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

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