-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMini-Max-Sum.cpp
More file actions
55 lines (41 loc) · 889 Bytes
/
Mini-Max-Sum.cpp
File metadata and controls
55 lines (41 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <bits/stdc++.h>
using namespace std;
int main() {
int num = 5;
long int arr[num];
long long int arr_sum=0;
long int lar=0;
long int sm=0;
for (int i = 0; i < num; ++i)
{
cin >> arr[i];
}
for (int i = 0; i < num; ++i)
{
arr_sum = arr_sum+arr[i];
}
for (int i = 0; i < num; ++i)
{
int time=0;
int low_time=0;
for (int j=0; j<num; ++j)
{
if (arr[i] >= arr[j] ) {
time++;
}
}
for (int j=0; j<num; ++j)
{
if (arr[i] <= arr[j] ) {
low_time++;
}
}
if (time == 5){lar = arr[i];}
else {time=0;}
if (low_time == 5){sm = arr[i];}
else {low_time=0;}
}
cout<<arr_sum-lar<<" ";
cout<<arr_sum-sm<<endl;
return 0;
}