Skip to content

Commit

Permalink
6730. 장애물 경주 난이도
Browse files Browse the repository at this point in the history
  • Loading branch information
cjy8922 authored Mar 16, 2021
1 parent be225aa commit a8103a5
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions 2021_03/SWEA_6730.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int T;
cin >> T;

for (int test_case = 1; test_case <= T; test_case++) {
int n;
cin >> n;

vector<int> level(n);
for (int i = 0; i < n; i++) cin >> level[i];

int up = 0, down = 0;
for (int i = 0; i < n - 1; i++) {
if (level[i] < level[i + 1]) {
up = max(up, level[i + 1] - level[i]);
}

else if (level[i] > level[i + 1]) {
down = max(down, level[i] - level[i + 1]);
}
}

cout << "#" << test_case << " " << up << " " << down << endl;
}
}

0 comments on commit a8103a5

Please sign in to comment.