Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.007 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.011 s | 1 KBi |
#7 |
Correcto
|
0.048 s | 2 KBi |
#8 |
Correcto
|
0.055 s | 2 KBi |
#9 |
Correcto
|
0.059 s | 2 KBi |
#10 |
Correcto
|
0.054 s | 2 KBi |
#11 |
Correcto
|
0.056 s | 3 KBi |
#12 |
Correcto
|
0.059 s | 3 KBi |
#13 |
Correcto
|
0.045 s | 2 KBi |
#14 |
Correcto
|
0.053 s | 2 KBi |
#15 |
Correcto
|
0.096 s | 2 KBi |
#16 |
Correcto
|
0.083 s | 3 KBi |
#17 |
Correcto
|
0.079 s | 2 KBi |
#18 |
Correcto
|
0.055 s | 2 KBi |
#19 |
Correcto
|
0.044 s | 2 KBi |
#20 |
Correcto
|
0.051 s | 2 KBi |
#21 |
Correcto
|
0.043 s | 2 KBi |
#22 |
Correcto
|
0.129 s | 2 KBi |
#23 |
Correcto
|
0.122 s | 2 KBi |
#24 |
Correcto
|
0.138 s | 2 KBi |
#25 |
Correcto
|
0.117 s | 2 KBi |
#26 |
Correcto
|
0.165 s | 2 KBi |
#27 |
Correcto
|
0.13 s | 2 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;cin>>n; vector<int> v(n); for(int i=0;i<n;i++)cin>>v[i]; sort(v.begin(),v.end()); for(int num:v)cout<<num<<' '; cout<<endl; return 0; }