Submission #318039

# Submission time Handle Problem Language Result Execution time Memory
318039 2020-10-31T10:05:00 Z Dymo Global Warming (CEOI18_glo) C++14
58 / 100
450 ms 8168 KB
#include<bits/stdc++.h>

using namespace std;


#define pb    push_back
#define eb   emplace_back
#define ll  int
#define pll pair<ll,ll>
#define ff first
#define ss second
#define endl "\n"
const ll maxn=2e5+50;
const ll mod =998244353 ;
const ll base=3e18;
vector<ll> vt;

ll st[2][4*maxn];
ll a[maxn];

void update(ll id,ll left,ll right,ll x,ll diff,ll t )
{
    if (x>right||x<left) return ;
    if (right==left )
    {
        st[t][id]=max(st[t][id],diff);
        return ;
    }
    ll mid=(left+right)/2;
    update(id*2,left,mid, x, diff,t);
    update(id*2+1, mid+1, right, x, diff,t);
    st[t][id]=max(st[t][id*2],st[t][id*2+1]);
}
ll get(ll id,ll left,ll right,ll x,ll y,ll t)
{
    if (x>right||y<left||x> y) return 0;
    if (x<=left&&y>=right)
    {
        return st[t][id];
    }
    ll mid=(left+right)/2;
    return max(get(id*2,left,mid, x, y, t ),get(id*2+1, mid+1, right, x, y, t));

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, x ;
    cin>> n>> x ;
    vt.pb(-1e15);
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
        vt.pb(a[i]);
        vt.pb(a[i]-x);
    }
    sort(vt.begin(),vt.end());
    vt.resize(unique(vt.begin(),vt.end())-vt.begin());
    ll ans=0;
    //cout <<vt.size()<<endl;
    /*for (auto to:vt)
    {
        cout <<to<<endl;
    }*/
   for (int i=1;i<=n;i++)
    {
        ll h=lower_bound(vt.begin(),vt.end(),a[i])-vt.begin();
        ll t=get(1,1,vt.size()-1,1,h-1,0)+1;
      //  cout <<1<<" "<<1<<" "<<vt.size()-1<<" "<<1<<" "<<h-1<<" "<<0<<endl;
        ll p=get(1,1,vt.size()-1,1,h-1,1)+1;
        update(1,1,vt.size()-1,h,t,0);
      //  cout <<1<<" "<<1<<" "<<vt.size()<<"
         update(1,1,vt.size()-1,h,p,1);
        ll h1=lower_bound(vt.begin(),vt.end(),a[i]-x)-vt.begin();
         update(1,1,vt.size()-1,h1,t,1);
        //cout <<t<<" "<<p<<" "<<h<<endl;
       // cout <<h<<" "<<h-1<<endl;
        ans=max(ans,t);
        ans=max(ans,p);
    }
    //update(1,1,vt.size()-1,4,2,0);
   // cout <<get(1,1,vt.size()-1,1,3,0)<<endl ;
    cout <<ans<<endl;
/*10 10
1 1 1 1 1 1 2 2 2 1
*/



}

Compilation message

glo.cpp:15:15: warning: overflow in conversion from 'double' to 'int' changes value from '3.0e+18' to '2147483647' [-Woverflow]
   15 | const ll base=3e18;
      |               ^~~~
glo.cpp: In function 'int main()':
glo.cpp:52:11: warning: overflow in conversion from 'double' to 'std::vector<int>::value_type' {aka 'int'} changes value from '-1.0e+15' to '-2147483648' [-Woverflow]
   52 |     vt.pb(-1e15);
      |           ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 2 ms 388 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 448 ms 8064 KB Output is correct
2 Correct 445 ms 8024 KB Output is correct
3 Correct 446 ms 8168 KB Output is correct
4 Correct 450 ms 8152 KB Output is correct
5 Correct 251 ms 6104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 3588 KB Output is correct
2 Correct 101 ms 3556 KB Output is correct
3 Correct 99 ms 3564 KB Output is correct
4 Correct 64 ms 2528 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 65 ms 2400 KB Output is correct
7 Correct 84 ms 3704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 225 ms 5856 KB Output is correct
2 Correct 234 ms 5728 KB Output is correct
3 Runtime error 64 ms 6872 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 2 ms 388 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 2 ms 364 KB Output is correct
27 Correct 448 ms 8064 KB Output is correct
28 Correct 445 ms 8024 KB Output is correct
29 Correct 446 ms 8168 KB Output is correct
30 Correct 450 ms 8152 KB Output is correct
31 Correct 251 ms 6104 KB Output is correct
32 Correct 107 ms 3588 KB Output is correct
33 Correct 101 ms 3556 KB Output is correct
34 Correct 99 ms 3564 KB Output is correct
35 Correct 64 ms 2528 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 65 ms 2400 KB Output is correct
38 Correct 84 ms 3704 KB Output is correct
39 Correct 225 ms 5856 KB Output is correct
40 Correct 234 ms 5728 KB Output is correct
41 Runtime error 64 ms 6872 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Halted 0 ms 0 KB -