Submission #861190

# Submission time Handle Problem Language Result Execution time Memory
861190 2023-10-15T15:31:04 Z Requiem Global Warming (CEOI18_glo) C++17
100 / 100
52 ms 10132 KB
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define MOD 1000000007
#define INF 1e18
#define fi first
#define se second
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define sz(a) ((int)(a).size())
#define pi 3.14159265359
#define TASKNAME "globalwarming"
template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; } 
template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; } 
using namespace std; 
typedef pair<int,int> ii; 
typedef pair<int,ii> iii; 
typedef vector<int> vi; 
const int MAXN = 2e5 + 9;
int a[MAXN],lisright[MAXN],lisleft[MAXN];
int n,x,lis[MAXN],dp[MAXN];

main() 
{ 
    fast; 
    // freopen(TASKNAME".inp","r",stdin); 
    // freopen(TASKNAME".out","w",stdout); 
    cin>>n>>x;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    memset(lis,0x3f,sizeof(lis));
    for(int i=1;i<=n;i++){
        int l=1,r=n,res=0;
        while(l<=r){
            int mid = (l+r)>>1;
            if (lis[mid] < a[i]){
                res = mid;
                l = mid + 1;
            }
            else r = mid - 1;
        }
        lis[res+1] = a[i];
        lisleft[i] = res + 1;
    }
    for(int i=1;i<=n;i++){
        a[i] -= x;
    }
    memset(lis,-0x3f,sizeof(lis));
    for(int i=n;i>=1;i--){
        int l=1,r=n,res=0;
        while(l<=r){
            int mid = (l+r)>>1;
            if (lis[mid] > a[i]){
                res = mid;
                l = mid + 1;
            }
            else r = mid - 1;
        }
        lisright[i] = res + 1;
        a[i] += x;
        l=1,r=n,res=0;
        while(l<=r){
            int mid = (l+r)>>1;
            if (lis[mid] > a[i]){
                res = mid;
                l = mid + 1;
            }
            else r = mid - 1;
        }
        lis[res+1] = a[i];
    }
    // for(int i=1;i<=n;i++){
    //     cout<<lisleft[i]<<' ';
    // }
    // cout<<endl;
    // for(int i=1;i<=n;i++){
    //     cout<<lisright[i]<<' ';
    // }
    // cout<<endl;
    int ans = 0;
    for(int i=1;i<=n;i++){
        ans=max(ans, lisleft[i] + lisright[i] - 1);
    }
    cout<<ans<<endl;
    
} 

Compilation message

glo.cpp:24:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   24 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6616 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6616 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6488 KB Output is correct
13 Correct 1 ms 6504 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 6612 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6616 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6488 KB Output is correct
13 Correct 1 ms 6504 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 6612 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
19 Correct 1 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 1 ms 6492 KB Output is correct
22 Correct 1 ms 6492 KB Output is correct
23 Correct 2 ms 6492 KB Output is correct
24 Correct 1 ms 6612 KB Output is correct
25 Correct 1 ms 6492 KB Output is correct
26 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 9640 KB Output is correct
2 Correct 49 ms 9304 KB Output is correct
3 Correct 49 ms 9356 KB Output is correct
4 Correct 51 ms 9300 KB Output is correct
5 Correct 37 ms 8796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 7516 KB Output is correct
2 Correct 12 ms 7260 KB Output is correct
3 Correct 12 ms 7416 KB Output is correct
4 Correct 10 ms 7004 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 10 ms 7004 KB Output is correct
7 Correct 10 ms 7404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 8072 KB Output is correct
2 Correct 20 ms 8280 KB Output is correct
3 Correct 41 ms 9820 KB Output is correct
4 Correct 36 ms 9052 KB Output is correct
5 Correct 19 ms 7772 KB Output is correct
6 Correct 29 ms 9052 KB Output is correct
7 Correct 31 ms 9696 KB Output is correct
8 Correct 17 ms 8536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6616 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6488 KB Output is correct
13 Correct 1 ms 6504 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 6612 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
19 Correct 1 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 1 ms 6492 KB Output is correct
22 Correct 1 ms 6492 KB Output is correct
23 Correct 2 ms 6492 KB Output is correct
24 Correct 1 ms 6612 KB Output is correct
25 Correct 1 ms 6492 KB Output is correct
26 Correct 1 ms 6492 KB Output is correct
27 Correct 52 ms 9640 KB Output is correct
28 Correct 49 ms 9304 KB Output is correct
29 Correct 49 ms 9356 KB Output is correct
30 Correct 51 ms 9300 KB Output is correct
31 Correct 37 ms 8796 KB Output is correct
32 Correct 14 ms 7516 KB Output is correct
33 Correct 12 ms 7260 KB Output is correct
34 Correct 12 ms 7416 KB Output is correct
35 Correct 10 ms 7004 KB Output is correct
36 Correct 1 ms 6492 KB Output is correct
37 Correct 10 ms 7004 KB Output is correct
38 Correct 10 ms 7404 KB Output is correct
39 Correct 24 ms 8072 KB Output is correct
40 Correct 20 ms 8280 KB Output is correct
41 Correct 41 ms 9820 KB Output is correct
42 Correct 36 ms 9052 KB Output is correct
43 Correct 19 ms 7772 KB Output is correct
44 Correct 29 ms 9052 KB Output is correct
45 Correct 31 ms 9696 KB Output is correct
46 Correct 17 ms 8536 KB Output is correct
47 Correct 24 ms 8280 KB Output is correct
48 Correct 25 ms 8280 KB Output is correct
49 Correct 52 ms 9808 KB Output is correct
50 Correct 36 ms 9240 KB Output is correct
51 Correct 29 ms 8548 KB Output is correct
52 Correct 38 ms 9304 KB Output is correct
53 Correct 36 ms 9296 KB Output is correct
54 Correct 34 ms 10132 KB Output is correct
55 Correct 39 ms 9800 KB Output is correct