-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1732FindtheHighestAltitude.cpp
More file actions
61 lines (47 loc) · 1.29 KB
/
1732FindtheHighestAltitude.cpp
File metadata and controls
61 lines (47 loc) · 1.29 KB
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
56
57
58
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
//https://leetcode.com/problems/number-of-increasing-paths-in-a-grid/description/
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vb vector<bool>
#define qii vector<int>
#define qpii queue<pii>
#define umipii unordered_map<int,pii>
#define pqpii priority_queue<pair<int,int>>
#define vd vector<double>
#define vs vector<string>
#define vvs vector<vs>
#define uo_si unordered_set<int>
#define uo_ss unordered_set<string>
#define ll long long
static const int ____ = []() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); return 0; }();
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,mmx,sse2,sse3,sse4")
int minx(const int& _a, const int& _b)
{
if (_a > _b)
return _b;
return _a;
}
int maxx(const int& _a, const int& _b)
{
if (_a < _b)
return _b;
return _a;
}
int largestAltitude(vector<int>& gain) {
int ans =0,temp = 0;
for (int i = 0; i < gain.size(); ++i) {
temp = temp + gain[i];
if(ans < temp) ans = temp;
}
return ans;
}
int main(int argc, const char* argv[]) {
vi gain = {-5,1,5,0,-7};
cout << largestAltitude(gain) << endl;
return argc;
}