#include <iostream>
//Se considera o multime de n numere reale. Se cere o submultime a sa, cu un numar maxim de elemente, astfel incat suma elementelor sale sa fie maxima.
float A[ 100 ] ,
B[ 100 ] ;
int n, m= 0 , i;
void greedy( ) {
for ( int i = 1 ; i <= n; ++ i) {
if ( A[ i] >= 0 ) { m++ ; B[ m] = A[ i] ; }
}
}
int main( int argc, char const * argv[ ] ) {
std:: cout << "n=" ;
std:: cin >> n;
for ( int i = 1 ; i <= n; ++ i) std:: cin >> A[ i] ;
greedy( ) ;
for ( int i = 1 ; i <= m; ++ i) std:: cout << B[ i] << " " ;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKLy9TZSBjb25zaWRlcmEgbyBtdWx0aW1lIGRlIG4gbnVtZXJlIHJlYWxlLiBTZSBjZXJlIG8gc3VibXVsdGltZSBhIHNhLCBjdSB1biBudW1hciBtYXhpbSBkZSBlbGVtZW50ZSwgYXN0ZmVsIGluY2F0IHN1bWEgZWxlbWVudGVsb3Igc2FsZSBzYSBmaWUgbWF4aW1hLgoKZmxvYXQgQVsxMDBdLAogICAgICBCWzEwMF07CmludCAgIG4sIG09MCwgaTsKCnZvaWQgZ3JlZWR5KCkgewogIGZvcihpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSB7CiAgICAgIGlmKEFbaV0+PTApIHsgbSsrOyBCW21dID0gQVtpXTsgfQogIH0KfQoKaW50IG1haW4oaW50IGFyZ2MsIGNoYXIgY29uc3QgKmFyZ3ZbXSkgewoKICBzdGQ6OmNvdXQ8PCJuPSI7CiAgc3RkOjpjaW4+Pm47CiAgZm9yKGludCBpID0gMTsgaSA8PSBuOyArK2kpIHN0ZDo6Y2luPj5BW2ldOwogIGdyZWVkeSgpOwogIGZvcihpbnQgaSA9IDE7IGkgPD0gbTsgKytpKSBzdGQ6OmNvdXQ8PEJbaV08PCIgIjsKICByZXR1cm4gMDsKfQ==