답안 #455157

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
455157 2021-08-05T15:03:39 Z Yuisuyuno Global Warming (CEOI18_glo) C++14
100 / 100
65 ms 8540 KB
//Nguyen Huu Hoang Minh
#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
#define reset(x) memset(x, 0,sizeof(x))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define N 200005
#define remain(x) if (x > MOD) x -= MOD
#define ii pair<int, int>
#define iiii pair< ii , ii >
#define viiii vector< iiii >
#define vi vector<int>
#define vii vector< ii >
#define bit(x, i) (((x) >> (i)) & 1)
#define Task "test"
#define int long long

using namespace std;

typedef long double ld;
const int inf = 1e10;
const int minf = -1e10;

int n, x;
int a[N];

void readfile()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    if (fopen(Task".inp","r"))
    {
        freopen(Task".inp","r",stdin);
        //freopen(Task".out","w",stdout);
    }
    cin >> n >> x;
    for(int i=1; i<=n; i++) cin >> a[i];
}

int L[N];
int R[N];

void proc()
{
    vector<int> b(n+1,inf);
    b[0] = minf;
    for(int i=1; i<=n; i++){
        int k = lower_bound(all(b),a[i])-b.begin();
        L[i] = k;
        b[k] = a[i];
    }
    //for(int i=1; i<=n; i++) cout << L[i] << ' ';
    b = vector<int>(n+1,inf);
    int ans=0;
    for(int i=n; i>=1; i--){
        int k = lower_bound(all(b),-a[i]+x)-b.begin();
        //cout << k << " \n"[i==1];
        ans = max(ans,L[i]+k);
        k = lower_bound(all(b),-a[i])-b.begin();
        b[k] = -a[i];
    }
    cout << ans;
}

signed main()
{
    readfile();
    proc();
    return 0;
}

Compilation message

glo.cpp: In function 'void readfile()':
glo.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         freopen(Task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 216 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 216 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 216 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 8496 KB Output is correct
2 Correct 65 ms 8500 KB Output is correct
3 Correct 65 ms 8388 KB Output is correct
4 Correct 65 ms 8388 KB Output is correct
5 Correct 48 ms 7636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 2380 KB Output is correct
2 Correct 17 ms 2328 KB Output is correct
3 Correct 16 ms 2380 KB Output is correct
4 Correct 12 ms 2124 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 12 ms 2124 KB Output is correct
7 Correct 13 ms 2380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 4428 KB Output is correct
2 Correct 29 ms 4320 KB Output is correct
3 Correct 58 ms 8408 KB Output is correct
4 Correct 49 ms 7728 KB Output is correct
5 Correct 24 ms 3992 KB Output is correct
6 Correct 41 ms 7420 KB Output is correct
7 Correct 47 ms 8096 KB Output is correct
8 Correct 25 ms 4352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 216 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 320 KB Output is correct
27 Correct 64 ms 8496 KB Output is correct
28 Correct 65 ms 8500 KB Output is correct
29 Correct 65 ms 8388 KB Output is correct
30 Correct 65 ms 8388 KB Output is correct
31 Correct 48 ms 7636 KB Output is correct
32 Correct 16 ms 2380 KB Output is correct
33 Correct 17 ms 2328 KB Output is correct
34 Correct 16 ms 2380 KB Output is correct
35 Correct 12 ms 2124 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 12 ms 2124 KB Output is correct
38 Correct 13 ms 2380 KB Output is correct
39 Correct 30 ms 4428 KB Output is correct
40 Correct 29 ms 4320 KB Output is correct
41 Correct 58 ms 8408 KB Output is correct
42 Correct 49 ms 7728 KB Output is correct
43 Correct 24 ms 3992 KB Output is correct
44 Correct 41 ms 7420 KB Output is correct
45 Correct 47 ms 8096 KB Output is correct
46 Correct 25 ms 4352 KB Output is correct
47 Correct 31 ms 4388 KB Output is correct
48 Correct 37 ms 4384 KB Output is correct
49 Correct 63 ms 8504 KB Output is correct
50 Correct 48 ms 7644 KB Output is correct
51 Correct 39 ms 5840 KB Output is correct
52 Correct 48 ms 7800 KB Output is correct
53 Correct 47 ms 7748 KB Output is correct
54 Correct 50 ms 8540 KB Output is correct
55 Correct 54 ms 8508 KB Output is correct