Submission #1003821

# Submission time Handle Problem Language Result Execution time Memory
1003821 2024-06-20T18:28:35 Z MonoLith Global Warming (CEOI18_glo) C++17
Compilation error
0 ms 0 KB
/*
   ॐ नमो भगवते वासुदेवाय नमः
   ॐ भूर्भुव: स्व: तत्सवितुर्वरेण्यं भर्गो देवस्य धीमहि धियो यो न: प्रचोदयात्।
*/
// all hail Infront of almighty lord krishna (jai shri krishna ji)
  #include<bits/stdc++.h>
  #ifndef  ONLINE_JUDGE
  #include "debug.h"
  #else
  #define print(...) 1;
  #endif
  #include <ext/pb_ds/assoc_container.hpp>
  #include <ext/pb_ds/tree_policy.hpp>
  using namespace std;
  using namespace __gnu_pbds;
  #define int long long 
  const long long INF =1e18;
  template<class T>
  using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> ;
  template<typename T> 
  using ordered_multiset = tree<T, null_type,less_equal<T>, rb_tree_tag,tree_order_statistics_node_update>;
  const int N=1e5 + 10;
  const int mod = 998244353;  

  void Solve()
  {
    int n,x;
    cin>>n>>x;
    vector<int>a(n);
    for(int i=0;i<n;i++)
    {
      cin>>a[i];
    }
    vector<int>inc(n,1);
    int ans=0;
    for(int i=0;i<n;i++)
    {
      for(int j=0;j<i;j++)
      {
        if(a[j]<a[i])
        {
          inc[i]=max(inc[i],inc[j]+1);
        }
      }
      ans=max(ans,inc[i]);
    }
    vector<int>dec(n,1);
    for(int i=n-1;i>=0;i--)
    {
      for(int j=n-1;j>i;j--)
      {
        if(a[i]<a[j])
        {
          dec[i]=max(dec[i],dec[j]+1);
        }
      }
    }
    // deb(inc);
    // deb(dec);
    // deb(ans);
    for(int i=n-1;i>=0;i--)
    {
      for(int j=i-1;j>=0;j--)
      {
         if(a[j]<a[i]+x)
         {
          ans=max(ans,inc[j]+dec[i]);
         }
      }
    }
    cout<<ans<<"\n";
  }

  signed main()
  { 
    
      auto begin = std::chrono::high_resolution_clock::now();
      ios_base::sync_with_stdio(0);
      cin.tie(0);
      cout<<fixed;
      int t = 1;
      // cin >> t;

      for(int i = 1; i <= t; i++) 
      {
          // cout << "Case #" << i << ": ";
          Solve();
 
      }
      auto end = std::chrono::high_resolution_clock::now();
      auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
      // cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 
      return 0;       
  }

Compilation message

glo.cpp:8:12: fatal error: debug.h: No such file or directory
    8 |   #include "debug.h"
      |            ^~~~~~~~~
compilation terminated.