Five distinct numbers are given. Determine the sum of the top 3 of them.
the 5 natural numbers are distinct, ranging from 1 to 10000 inclusive
ex: [font=Menlo, Monaco, Consolas,]1 5 2 3 100[/font]
[font=Menlo, Monaco, Consolas,]output: 108[/font]
[font=Menlo, Monaco, Consolas,]pb source: https://www.pbinfo.ro/?pagina=probleme&id=559[/font]
[font=Menlo, Monaco, Consolas,]it gives me only 40 points[/font]
it fkin works idk why i cant get 100p :/
[shcode=cpp]
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int X[5];
cin >> X[0];
cin >> X[1];
cin >> X[2];
cin >> X[3];
cin >> X[4];
if (X[0]!=X[1] && X[0]!=X[2] && X[0]!=X[3] && X[0]!=X[4]) {
if (X[1]!=X[0] && X[1]!=X[2] && X[1]!=X[3] && X[1]!=X[4]) {
if (X[2]!=X[0] && X[2]!=X[1] && X[2]!=X[3] && X[2]!=X[4]) {
if (X[3]!=X[0] && X[3]!=X[1] && X[3]!=X[2] && X[3]!=X[4]) {
if (X[4]!=X[0] && X[4]!=X[1] && X[4]!=X[2] && X[4]!=X[3]) {
int MAX[6];
MAX[0] = max(X[0], X[1]);
MAX[1] = max(X[2], X[3]);
MAX[2] = max(X[4], X[0]);
MAX[3] = max(X[4], X[1]);
MAX[4] = max(X[4], X[2]);
MAX[5] = max(X[4], X[3]);
cout << MAX[0] + MAX[1] + MAX[2] << endl;
}
}
}
}
}
}
[/shcode]
the 5 natural numbers are distinct, ranging from 1 to 10000 inclusive
ex: [font=Menlo, Monaco, Consolas,]1 5 2 3 100[/font]
[font=Menlo, Monaco, Consolas,]output: 108[/font]
[font=Menlo, Monaco, Consolas,]pb source: https://www.pbinfo.ro/?pagina=probleme&id=559[/font]
[font=Menlo, Monaco, Consolas,]it gives me only 40 points[/font]
it fkin works idk why i cant get 100p :/
[shcode=cpp]
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int X[5];
cin >> X[0];
cin >> X[1];
cin >> X[2];
cin >> X[3];
cin >> X[4];
if (X[0]!=X[1] && X[0]!=X[2] && X[0]!=X[3] && X[0]!=X[4]) {
if (X[1]!=X[0] && X[1]!=X[2] && X[1]!=X[3] && X[1]!=X[4]) {
if (X[2]!=X[0] && X[2]!=X[1] && X[2]!=X[3] && X[2]!=X[4]) {
if (X[3]!=X[0] && X[3]!=X[1] && X[3]!=X[2] && X[3]!=X[4]) {
if (X[4]!=X[0] && X[4]!=X[1] && X[4]!=X[2] && X[4]!=X[3]) {
int MAX[6];
MAX[0] = max(X[0], X[1]);
MAX[1] = max(X[2], X[3]);
MAX[2] = max(X[4], X[0]);
MAX[3] = max(X[4], X[1]);
MAX[4] = max(X[4], X[2]);
MAX[5] = max(X[4], X[3]);
cout << MAX[0] + MAX[1] + MAX[2] << endl;
}
}
}
}
}
}
[/shcode]