답안 #169987

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
169987 2019-12-23T14:05:30 Z mhy908 Global Warming (CEOI18_glo) C++14
17 / 100
77 ms 5452 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const LL llinf=9000000000000000000;
const int inf=2000000000;
int n;
LL x, arr[200010];
vector<LL> lis, lds;
int dplis[200010], dplds[200010], ans;
int main()
{
    scanf("%d %lld", &n, &x);
    for(int i=1; i<=n; i++)scanf("%d", &arr[i]);
    for(int i=1; i<=n; i++){
        auto it=lower_bound(lis.begin(), lis.end(), arr[i]);
        if(it==lis.end())lis.pb(arr[i]);
        else *it=arr[i];
        dplis[i]=lower_bound(lis.begin(), lis.end(), arr[i+1]+x)-lis.begin();
    }
    ans=dplis[n];
    for(int i=n; i>=1; i--){
        auto it=lower_bound(lds.begin(), lds.end(), -arr[i]);
        if(it==lds.end())lds.pb(-arr[i]);
        else *it=-arr[i];
        dplds[i]=lds.size();
    }
    ans=dplds[1];
    for(int i=1; i<n; i++){
        ans=max(ans, dplis[i]+dplds[i+1]);
    }
    printf("%d", ans);
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:19:47: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'LL* {aka long long int*}' [-Wformat=]
     for(int i=1; i<=n; i++)scanf("%d", &arr[i]);
                                        ~~~~~~~^
glo.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %lld", &n, &x);
     ~~~~~^~~~~~~~~~~~~~~~~~~
glo.cpp:19:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=n; i++)scanf("%d", &arr[i]);
                            ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 77 ms 3484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 1144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 1912 KB Output is correct
2 Correct 35 ms 1916 KB Output is correct
3 Correct 69 ms 3548 KB Output is correct
4 Correct 50 ms 5448 KB Output is correct
5 Correct 25 ms 3184 KB Output is correct
6 Correct 43 ms 5452 KB Output is correct
7 Correct 46 ms 5140 KB Output is correct
8 Correct 29 ms 1912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -