CARVIEW |
Select Language
HTTP/2 200
date: Mon, 13 Oct 2025 08:30:16 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=0055aa2f41370a39c5703739f952792051e203d99b2bda4fe92aa8572f9f583ea%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22_xkkWQNwFRFk0zp_Y5GMllOgTbo7gyVo%22%3B%7D; HttpOnly; Path=/
cf-ray: 98dd79545e46c1b5-BLR
longest_increasing_subsequence - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- ll max_ll(ll x, ll y){
- return ((x>y)?(x):(y));
- }
- int main()
- {
- ll n;
- cin>>n;
- ll a[n+1];
- for (ll i=1; i<=n; i++) cin>>a[i];
- ll dp[n+1];
- multiset<pair<ll,ll>> s;
- s.insert({a[1],1});
- dp[1]=1;
- for (ll i=2; i<=n; i++){
- s.insert({a[i],i});
- dp[i]=1;
- for (auto it=s.find({a[i],i}); it!=s.begin(); it--){
- if ((*it).first<a[i]) dp[i]=max_ll(dp[i],dp[(*it).second]+1);
- }
- auto it=s.begin();
- if ((*it).first<a[i]) dp[i]=max_ll(dp[i],dp[(*it).second]+1);
- }
- for (ll i=1; i<=n; i++) dp[n]=max_ll(dp[n],dp[i]);
- cout<<dp[n];
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐⭐⭐GMAIL Logs (2FA disabled)⭐⭐
Java | 5 sec ago | 0.15 KB
-
💡 Instant BTC Profit Method ✅ Working
JavaScript | 6 sec ago | 0.24 KB
-
⭐⭐⭐Exploit 500$ in 15 Minutes⭐⭐
Java | 16 sec ago | 0.15 KB
-
💡 Instant BTC Profit Method ✅ Working
JavaScript | 18 sec ago | 0.24 KB
-
📌 Instant BTC Profit Method ✅ Working 5
JavaScript | 18 sec ago | 0.25 KB
-
⭐⭐⭐Exploit 500$ in 15 Minutes⭐⭐
Java | 26 sec ago | 0.15 KB
-
💵 Make 3000$ in 20 minutes 💵
JavaScript | 28 sec ago | 0.24 KB
-
⭐⭐⭐Make $15OO in 2O minutesV E⭐⭐
Java | 37 sec ago | 0.15 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand