Skip to content

Commit b5a2204

Browse files
Add files via upload
1 parent def144a commit b5a2204

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <iostream>
2+
#include <vector>
3+
4+
using namespace std;
5+
6+
int main()
7+
{
8+
int no_of_elements;
9+
cin >> no_of_elements;
10+
11+
vector <int> A(no_of_elements + 1);
12+
for(int i = 1; i <= no_of_elements; i++)
13+
{
14+
cin >> A[i];
15+
}
16+
17+
int segments = 0;
18+
for(int i = 1; i <= no_of_elements; i++)
19+
{
20+
int segments_starting_here = max(0, A[i] - A[i - 1]);
21+
segments += segments_starting_here;
22+
}
23+
24+
cout << segments << "\n";
25+
return 0;
26+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int height, base, hypotenuse;
8+
cin >> height >> base >> hypotenuse;
9+
10+
int area = (height*base)/2;
11+
cout << area << "\n";
12+
13+
return 0;
14+
}

0 commit comments

Comments
 (0)