TataVucko70

Untitled

Aug 13th, 2025
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. # include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX=1e6+11;
  5. long long dp[MAX];
  6.  
  7. int main()
  8. {
  9.     ios_base::sync_with_stdio(0);
  10.     cin.tie(0);cout.tie(0);
  11.  
  12.     dp[1]=6;
  13.     for(int i=2;i<=1e6;i++)
  14.     {
  15.         dp[i]=max(dp[i],dp[i-1]+i*3+2);
  16.     }
  17.  
  18.     long long n,ans=0;
  19.     cin>>n;
  20.     for(int i=1;i<=1e6;i++)
  21.     {
  22.         if(n>=dp[i]) ans=i;
  23.         else break;
  24.     }
  25.  
  26.     cout<<ans<<"\n";
  27.  
  28.     return 0;
  29. }
  30.  
  31.  
  32.  
Advertisement
Add Comment
Please, Sign In to add comment