Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 1 KBi |
#2 |
Correcto
|
0.005 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.005 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 1 KBi |
#6 |
Correcto
|
0.007 s | 1 KBi |
#7 |
Correcto
|
0.007 s | 1 KBi |
#8 |
Correcto
|
0.01 s | 1 KBi |
#9 |
Correcto
|
0.004 s | 1 KBi |
#10 |
Correcto
|
0.005 s | 1 KBi |
#11 |
Correcto
|
0.006 s | 1 KBi |
#12 |
Correcto
|
0.006 s | 1 KBi |
#include <bits/stdc++.h> #define IO ios_base::sync_with_stdio(false), cin.tie(nullptr) #define endl '\n' using namespace std; long long go(vector<int> &a, vector<int> &b, int k, int l, int i, int j, set<int> &s, long long acum){ if(k<=0)return acum; long long res = 0; s.insert(b[i]); acum += b[i]; if(s.size()>l){acum-=*s.begin();s.erase(s.begin());} res = max(res,a[i]+go(a,b,k-1,l,i+1,j,s,acum)); s.erase(b[i]); acum-=b[i]; s.insert(b[j]); acum += b[j]; if(s.size()>l)s.erase(s.begin()); res = max(res,b[i]+go(a,b,k-1,l,i,j-1,s,acum)); s.erase(b[j]); acum -= b[j]; return res; } int main(){ IO;/* int n;cin>>n; vector<int> a(n+1),b(n+1); for(int i=1;i<=n;i++)cin>>a[i]; for(int i=1;i<=n;i++)cin>>b[i]; int k,l;cin>>k>>l; set<int> s; cout<<go(a,b,k,l,1,n,s,0)<<endl; */ int n,a,b;cin>>n; cin>>a; bool flag = false; for(int i=1;i<n;i++){ cin>>b; if(b<a)flag = true; a = b; } if(flag)cout<<"Desordenado"<<endl; else cout<<"Ordenado"<<endl; return 0; }