제출 #1104763

#제출 시각아이디문제언어결과실행 시간메모리
1104763KasymKGlobal Warming (CEOI18_glo)C++17
100 / 100
50 ms5456 KiB
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 2e5+5;
const int INF = 1e9;
int cep[N], sag[N], v[N], dp[N];

int main(){
    int n, x; scanf("%d%d", &n, &x);
    for(int i = 0; i < n; ++i){
        int x; scanf("%d", &x);
        v[i] = x;
    }
    auto reload = [&]() {
        for(int i = 0; i < n; ++i)
            dp[i] = INF;
    };
    int answer = 0;
    reload();
    for(int i = 0; i < n; ++i){
        int j = lower_bound(dp, dp+n, v[i])-dp;
        dp[j] = v[i], cep[i] = j+1;
    }
    reload();
    for(int i = n-1; i >= 0; --i){
        int j = lower_bound(dp, dp+n, -v[i]+x)-dp;
        sag[i] = j;
        j = lower_bound(dp, dp+n, -v[i])-dp;
        dp[j] = -v[i];
    }
    for(int i = 0; i < n; ++i)
        umax(answer, cep[i]+sag[i]);
    printf("%d\n", answer);
    return 0;
}

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

glo.cpp: In function 'int main()':
glo.cpp:20:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     int n, x; scanf("%d%d", &n, &x);
      |               ~~~~~^~~~~~~~~~~~~~~~
glo.cpp:22:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         int x; scanf("%d", &x);
      |                ~~~~~^~~~~~~~~~
#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...