Submission #314070

# Submission time Handle Problem Language Result Execution time Memory
314070 2020-10-18T07:01:36 Z tushar_2658 Global Warming (CEOI18_glo) C++14
100 / 100
86 ms 7800 KB
#include "bits/stdc++.h"
using namespace std;

const int maxn = 200005;
using ll = long long;

ll a[maxn], x;
int n;

int main(int argc, char const *argv[])
{
  scanf("%d %lld", &n, &x);
  for(int i = 1; i <= n; ++i){
    scanf("%lld", &a[i]);
  }
  vector<ll> dp(n + 1, 1e15);
  dp[0] = -1e15;
  vector<int> L(n + 1);
  for(int i = 1; i <= n; ++i){
    int idx = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
    dp[idx] = a[i];
    L[i] = idx;
  }
  vector<ll> dp1(n + 1, 1e15);
  dp1[0] = -1e15;
  int ans = 0;
  for(int i = n; i >= 1; --i){
    int idx = lower_bound(dp1.begin(), dp1.end(), -a[i]) - dp1.begin();
    int idx1 = lower_bound(dp1.begin(), dp1.end(), -a[i] + x) - dp1.begin();
    dp1[idx] = -a[i];
    ans = max(ans, L[i] + idx1 - 1);
  }
  cout << ans << endl;

  return 0;
}

Compilation message

glo.cpp: In function 'int main(int, const char**)':
glo.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |   scanf("%d %lld", &n, &x);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
glo.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     scanf("%lld", &a[i]);
      |     ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 360 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 360 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 5804 KB Output is correct
2 Correct 83 ms 7800 KB Output is correct
3 Correct 83 ms 7672 KB Output is correct
4 Correct 84 ms 7672 KB Output is correct
5 Correct 63 ms 6904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1664 KB Output is correct
2 Correct 19 ms 2176 KB Output is correct
3 Correct 19 ms 2176 KB Output is correct
4 Correct 15 ms 2048 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 15 ms 2040 KB Output is correct
7 Correct 18 ms 2176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 3064 KB Output is correct
2 Correct 38 ms 4088 KB Output is correct
3 Correct 78 ms 7672 KB Output is correct
4 Correct 79 ms 7032 KB Output is correct
5 Correct 30 ms 3704 KB Output is correct
6 Correct 53 ms 6776 KB Output is correct
7 Correct 57 ms 7364 KB Output is correct
8 Correct 33 ms 4088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 360 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 81 ms 5804 KB Output is correct
28 Correct 83 ms 7800 KB Output is correct
29 Correct 83 ms 7672 KB Output is correct
30 Correct 84 ms 7672 KB Output is correct
31 Correct 63 ms 6904 KB Output is correct
32 Correct 19 ms 1664 KB Output is correct
33 Correct 19 ms 2176 KB Output is correct
34 Correct 19 ms 2176 KB Output is correct
35 Correct 15 ms 2048 KB Output is correct
36 Correct 0 ms 256 KB Output is correct
37 Correct 15 ms 2040 KB Output is correct
38 Correct 18 ms 2176 KB Output is correct
39 Correct 40 ms 3064 KB Output is correct
40 Correct 38 ms 4088 KB Output is correct
41 Correct 78 ms 7672 KB Output is correct
42 Correct 79 ms 7032 KB Output is correct
43 Correct 30 ms 3704 KB Output is correct
44 Correct 53 ms 6776 KB Output is correct
45 Correct 57 ms 7364 KB Output is correct
46 Correct 33 ms 4088 KB Output is correct
47 Correct 41 ms 4092 KB Output is correct
48 Correct 40 ms 4088 KB Output is correct
49 Correct 86 ms 7800 KB Output is correct
50 Correct 62 ms 6904 KB Output is correct
51 Correct 47 ms 5368 KB Output is correct
52 Correct 61 ms 7032 KB Output is correct
53 Correct 56 ms 7032 KB Output is correct
54 Correct 60 ms 7800 KB Output is correct
55 Correct 70 ms 7800 KB Output is correct