제출 #395554

#제출 시각아이디문제언어결과실행 시간메모리
395554Qw3rTyGlobal Warming (CEOI18_glo)C++11
5 / 100
2080 ms1284 KiB
#include <bits/stdc++.h>
#define INF 1e9+5
using namespace std;

const int maxN = 1e5+5;

int a[maxN];
int b[maxN];
int f[maxN]; //f[i] = longest decreasing subsequence of b that ends on N+1-i
int g[maxN]; //g[i] = longest increasing subsequence of a that ends on i
int N,d;

void testIO(){
    freopen("../test.in","r",stdin);
    return;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //testIO();
    cin >> N >> d;
    for(int i = 1; i <= N; ++i)cin >> a[i];
    for(int i = 1; i <= N; ++i)b[i] = a[N+1-i];
    b[0] = INF;
    for(int i = 1; i <= N; ++i){
        for(int j = 0; j < i; ++j){
            if(b[i] < b[j])f[i] = max(f[i],f[j]+1);
        }
    }
    a[0] = -INF;
    for(int i = 1; i <= N; ++i){
        for(int j = 0; j < i; ++j){
            if(a[i] > a[j])g[i] = max(g[i],g[j]+1);
        }
    }
    int res = 0;
    for(int i = 1; i <= N; ++i){
        if(a[i-1] - d <= a[i])res = max(res, g[i-1] + f[N+1-i]);
    }
    cout << res << '\n';
    return 0;
}

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

glo.cpp: In function 'void testIO()':
glo.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     freopen("../test.in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...